diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-07-04 02:20:19 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-07-04 02:20:19 +0530 |
commit | 1cac547f4aa9d15a56281c4b5a9db5e8f3d97c47 (patch) | |
tree | 675023739bfcb3035a7a54bb06e28f440c9b4422 /ui | |
parent | 9228897f84d898a7736f1f6df9b2aac005a89514 (diff) |
added anime info with searching
Diffstat (limited to 'ui')
-rw-r--r-- | ui/search.go | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/ui/search.go b/ui/search.go index 8e6ac0d..baea6f1 100644 --- a/ui/search.go +++ b/ui/search.go @@ -32,14 +32,64 @@ import ( func AnimeSearch(label, searchString string) a.Anime { animes := mal.SearchAnime(searchString) + for i, anime := range animes { + animes[i].DurationSeconds = anime.DurationSeconds / 60 + + /* I cant find a way to add functions to the details template + * So I am formatting the studios as one string + * and setting as the first studio name. pretty hacky. */ + if len(anime.Studios) > 0 { + var studiosFormatted string + for j, studio := range anime.Studios { + studiosFormatted = studiosFormatted + studio.Name + // setting other studio names as "" + animes[i].Studios[j].Name = "" + if j != len(anime.Studios) - 1 { + studiosFormatted = studiosFormatted + ", " + } + } + animes[i].Studios[0].Name = studiosFormatted + } + + var ratingFormatted string + switch anime.Rating { + case "g": + ratingFormatted = "G - All Ages" + case "pg": + ratingFormatted = "PG - Children" + case "pg_13": + ratingFormatted = "PG13 - Teens 13 and Older" + case "r": + ratingFormatted = "R - 17+ (violence & profanity)" + case "r+": + ratingFormatted = "R+ - Profanity & Mild Nudity" + case "rx": + ratingFormatted = "Rx - Hentai" + default: + ratingFormatted = anime.Rating + } + animes[i].Rating = ratingFormatted + } + template := &p.SelectTemplates { Label: "{{ . }}", Active: "{{ .Title | magenta }}", Inactive: "{{ .Title }}", Selected: "{{ .Title | blue }}", + // TODO: format and maybe color code details Details: ` --------- {{ .Title }} ---------- -More Details To Be Added Later +{{ "Number of Episodes:" | blue | bold }} {{ .NumEpisodes }} +{{ "English Title:" | blue | bold }} {{ .AltTitles.En }} +{{ "Japanese Title:" | blue | bold }} {{ .AltTitles.Ja }} +{{ "Original Run:" | blue | bold }} {{ .StartDate }} - {{ .EndDate }} ({{ .StartSeason.Name }} {{ .StartSeason.Year }}) +{{ "Mean Score:" | blue | bold }} {{ .MeanScore }} +{{ "Rank:" | blue | bold }} {{ .Rank }} +{{ "Type:" | blue | bold }} {{ .MediaType }} +{{ "Status:" | blue | bold }} {{ .Status }} +{{ "Average Duration:" | blue | bold }} {{ .DurationSeconds }} minutes +{{ "Rating:" | blue | bold }} {{ .Rating }} +{{ "Studios:" | blue | bold }} {{ range .Studios }}{{ .Name }}{{ end }} `, } |