aboutsummaryrefslogtreecommitdiff
path: root/ui/search.go
diff options
context:
space:
mode:
Diffstat (limited to 'ui/search.go')
-rw-r--r--ui/search.go52
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 }}
`,
}