diff options
-rw-r--r-- | cmd/root.go | 2 | ||||
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | go.sum | 4 | ||||
-rw-r--r-- | ui/search.go | 53 |
4 files changed, 36 insertions, 25 deletions
diff --git a/cmd/root.go b/cmd/root.go index d9346dd..e575a92 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -34,7 +34,7 @@ var ( var rootCmd = &cobra.Command{ Use: "macli", - Version: "v1.20.2" + " " + runtime.GOOS + "/" + runtime.GOARCH, + Version: "v1.20.3" + " " + runtime.GOOS + "/" + runtime.GOARCH, Short: "macli - Unofficial CLI-Based MyAnimeList Client.", Long: "macli is an unofficial MyAnimeClient for use inside the terminal.\n" + @@ -9,7 +9,7 @@ require ( github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.16.0 github.com/zalando/go-keyring v0.2.3 - vidhukant.com/mg v0.0.4 + vidhukant.com/mg v0.0.6 ) require ( @@ -514,5 +514,5 @@ honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -vidhukant.com/mg v0.0.4 h1:vrI8sAQ7uQTNrDne2uM5M3kmAE4JVBc1B+9JfzgKgyU= -vidhukant.com/mg v0.0.4/go.mod h1:2Iqo+jgEE8hINUNL1AoFrcs8UWCzuPelx/8lEPIUtqE= +vidhukant.com/mg v0.0.6 h1:Bl0jgGq18efd0y7whTnawn2qFtp70eC9x4X+EdQhCqE= +vidhukant.com/mg v0.0.6/go.mod h1:2Iqo+jgEE8hINUNL1AoFrcs8UWCzuPelx/8lEPIUtqE= diff --git a/ui/search.go b/ui/search.go index 9c077aa..3ae3102 100644 --- a/ui/search.go +++ b/ui/search.go @@ -67,6 +67,7 @@ func AnimeSearch(label, searchString string) mg.Anime { } animes[i].Studios[0].Name = studiosFormatted } + // same with genres if len(anime.Genres) > 0 { var genresFormatted string @@ -109,9 +110,9 @@ func AnimeSearch(label, searchString string) mg.Anime { Details: ` --------- {{ .Title }} ---------- {{ "Number of Episodes:" | blue | bold }} {{ if .NumEpisodes }}{{ .NumEpisodes }}{{ else }}{{ "unknown" | faint }}{{ end }} -{{ "English Title:" | blue | bold }} {{ if .AltTitles.En }}{{ .AltTitles.En }}{{ else }}{{ "none" | faint }}{{ end }} -{{ "Japanese Title:" | blue | bold }} {{ if .AltTitles.Ja }}{{ .AltTitles.Ja }}{{ else }}{{ "none" | faint }}{{ end }} -{{ "Original Run:" | blue | bold }} {{ if .StartDate }}{{ .StartDate | cyan }}{{ else }}{{ "unknown" | faint }}{{ end }} - {{ if .EndDate }}{{ .EndDate | yellow }}{{ else }}{{ "unknown" | faint }}{{end}} {{ if .StartSeason.Year }}({{ .StartSeason.Name }} {{ .StartSeason.Year }}){{ else }}{{ end }} +{{ "English Title:" | blue | bold }} {{ if .AltTitles.EnglishTitle }}{{ .AltTitles.EnglishTitle }}{{ else }}{{ "none" | faint }}{{ end }} +{{ "Japanese Title:" | blue | bold }} {{ if .AltTitles.JapaneseTitle }}{{ .AltTitles.JapaneseTitle }}{{ else }}{{ "none" | faint }}{{ end }} +{{ "Original Run:" | blue | bold }} {{ if .StartDate }}{{ .StartDate | cyan }}{{ else }}{{ "unknown" | faint }}{{ end }} - {{ if .EndDate }}{{ .EndDate | yellow }}{{ else }}{{ "unknown" | faint }}{{end}} {{ if .Season.Year }}({{ .Season.Name }} {{ .Season.Year }}){{ else }}{{ end }} {{ "Mean Score:" | blue | bold }} {{ if .MeanScore }}{{ .MeanScore }}{{ else }}{{ "unknown" | faint }}{{ end }} {{ "Rank:" | blue | bold }} {{ if .Rank }}{{ .Rank }}{{ else }}{{ "unknown" | faint }}{{ end }} {{ "Type:" | blue | bold }} {{ .MediaType }} @@ -150,7 +151,7 @@ func AnimeSearch(label, searchString string) mg.Anime { var MangaSearchFields []string = []string { "num_chapters", "num_volumes", "alternative_titles", "start_date", - "end_date", "mean", "rank", + "end_date", "mean", "rank", "genres", "media_type", "status", "authors", } @@ -169,20 +170,29 @@ func MangaSearch(label, searchString string) mg.Manga { for i, manga := range mangas { /* I cant find a way to add functions to the details template * So I am formatting the authors as one string - * and setting as the first studio name. pretty hacky. */ - // TODO: uncomment this when MAL2Go is ready to handle author data - // if len(manga.Authors) > 0 { - // var authorsFormatted string - // for j, author := range manga.Authors { - // authorsFormatted = authorsFormatted + author.Name - // // setting other author names as "" - // mangas[i].Authors[j].Name = "" - // if j != len(manga.Authors) - 1 { - // authorsFormatted = authorsFormatted + ", " - // } - // } - // mangas[i].Authors[0].Name = authorsFormatted - // } + * and setting as the first author name. pretty hacky. */ + if len(manga.Authors) > 0 { + var authorsFormatted string + for j, author := range manga.Authors { + authorsFormatted = authorsFormatted + author.Details.FirstName + if author.Details.LastName != "" { + authorsFormatted = authorsFormatted + " " + author.Details.LastName + } + + if author.Role != "" { + authorsFormatted = authorsFormatted + " (" + author.Role + ")" + } + + // setting other author names as "" + mangas[i].Authors[j].Details.FirstName = "" + mangas[i].Authors[j].Details.LastName = "" + if j != len(manga.Authors) - 1 { + authorsFormatted = authorsFormatted + ", " + } + } + mangas[i].Authors[0].Details.FirstName = authorsFormatted + } + // same with genres if len(manga.Genres) > 0 { var genresFormatted string @@ -207,14 +217,15 @@ func MangaSearch(label, searchString string) mg.Manga { --------- {{ .Title }} ---------- {{ "Number of Volumes:" | blue | bold }} {{ if .NumVolumes }}{{ .NumVolumes }}{{ else }}{{ "unknown" | faint }}{{ end }} {{ "Number of Chapters:" | blue | bold }} {{ if .NumChapters }}{{ .NumChapters }}{{ else }}{{ "unknown" | faint }}{{ end }} -{{ "English Title:" | blue | bold }} {{ if .AltTitles.En }}{{ .AltTitles.En }}{{ else }}{{ "none" | faint }}{{ end }} -{{ "Japanese Title:" | blue | bold }} {{ if .AltTitles.Ja }}{{ .AltTitles.Ja }}{{ else }}{{ "none" | faint }}{{ end }} +{{ "English Title:" | blue | bold }} {{ if .AltTitles.EnglishTitle }}{{ .AltTitles.EnglishTitle }}{{ else }}{{ "none" | faint }}{{ end }} +{{ "Japanese Title:" | blue | bold }} {{ if .AltTitles.JapaneseTitle }}{{ .AltTitles.JapaneseTitle }}{{ else }}{{ "none" | faint }}{{ end }} {{ "Original Run:" | blue | bold }} {{ if .StartDate }}{{ .StartDate | cyan }}{{ else }}{{ "unknown" | faint }}{{ end }} - {{ if .EndDate }}{{ .EndDate | yellow }}{{ else }}{{ "unknown" | faint }}{{end}} {{ "Mean Score:" | blue | bold }} {{ if .MeanScore }}{{ .MeanScore }}{{ else }}{{ "unknown" | faint }}{{ end }} {{ "Rank:" | blue | bold }} {{ if .Rank }}{{ .Rank }}{{ else }}{{ "unknown" | faint }}{{ end }} {{ "Type:" | blue | bold }} {{ .MediaType }} {{ "Status:" | blue | bold }} {{ .Status }} -{{ "Authors:" | blue | bold }} {{ "coming soon" | faint }} +{{ "Authors:" | blue | bold }} {{ if .Authors }}{{ range .Authors }}{{ .Details.FirstName }}{{ end }}{{ else }}{{ "unknown" | faint }}{{ end }} +{{ "Genres:" | blue | bold }} {{ if .Genres }}{{ range .Genres }}{{ .Name }}{{ end }}{{ else }}{{ "unknown" | faint }}{{ end }} `, } |