aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-07-04 18:06:59 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-07-04 18:06:59 +0530
commit4879f9849d224849cd9118a68f079bbd917b2b14 (patch)
treeee958a2381d598e9e25606f8a0e83ee7d7c949c1
parent2051cb36d0153b7ab5aaa15e0c700047560ca7a9 (diff)
formatted manga info shown when searching manga
-rw-r--r--cmd/version.go2
-rw-r--r--ui/search.go76
-rw-r--r--ui/ui.go4
3 files changed, 65 insertions, 17 deletions
diff --git a/cmd/version.go b/cmd/version.go
index e864597..ddca5e4 100644
--- a/cmd/version.go
+++ b/cmd/version.go
@@ -24,7 +24,7 @@ import (
"github.com/spf13/cobra"
)
-var version string = "v1.7.0"
+var version string = "v1.7.2"
var versionCmd = &cobra.Command {
Use: "version",
diff --git a/ui/search.go b/ui/search.go
index 2e266dd..0b1b4b2 100644
--- a/ui/search.go
+++ b/ui/search.go
@@ -29,12 +29,12 @@ import (
)
var AnimeSearchFields []string = []string {
- "num_episodes", "synopsis",
- "alternative_titles", "start_date",
- "end_date", "mean", "start_season",
- "rank", "media_type", "status",
+ "num_episodes", "alternative_titles",
+ "start_date", "end_date", "mean",
+ "start_season", "rank",
+ "media_type", "status",
"average_episode_duration",
- "rating", "studios",
+ "rating", "studios", "genres",
}
// only search animes probably only now
@@ -59,6 +59,19 @@ func AnimeSearch(label, searchString string) a.Anime {
}
animes[i].Studios[0].Name = studiosFormatted
}
+ // same with genres
+ if len(anime.Genres) > 0 {
+ var genresFormatted string
+ for j, genre := range anime.Genres {
+ genresFormatted = genresFormatted + genre.Name
+ // setting other genre names as ""
+ animes[i].Genres[j].Name = ""
+ if j != len(anime.Genres) - 1 {
+ genresFormatted = genresFormatted + ", "
+ }
+ }
+ animes[i].Genres[0].Name = genresFormatted
+ }
var ratingFormatted string
switch anime.Rating {
@@ -85,7 +98,6 @@ func AnimeSearch(label, searchString string) a.Anime {
Active: "{{ .Title | magenta }}",
Inactive: "{{ .Title }}",
Selected: "{{ .Title | blue }}",
- // TODO: format and maybe color code details
Details: `
--------- {{ .Title }} ----------
{{ "Number of Episodes:" | blue | bold }} {{ if .NumEpisodes }}{{ .NumEpisodes }}{{ else }}{{ "unknown" | faint }}{{ end }}
@@ -99,6 +111,7 @@ func AnimeSearch(label, searchString string) a.Anime {
{{ "Average Duration:" | blue | bold }} {{ if .DurationSeconds }}{{ .DurationSeconds }} minutes{{ else }}{{ "unknown" | faint }}{{ end }}
{{ "Rating:" | blue | bold }} {{ if .Rating }}{{ .Rating }}{{ else }}{{ "unknown" | faint }}{{ end }}
{{ "Studios:" | blue | bold }} {{ if .Studios }}{{ range .Studios }}{{ .Name }}{{ end }}{{ else }}{{ "unknown" | faint }}{{ end }}
+{{ "Genres:" | blue | bold }} {{ if .Genres }}{{ range .Genres }}{{ .Name }}{{ end }}{{ else }}{{ "unknown" | faint }}{{ end }}
`,
}
@@ -127,15 +140,47 @@ func AnimeSearch(label, searchString string) a.Anime {
}
var MangaSearchFields []string = []string {
- "num_chapters", "num_volumes", "synopsis",
+ "num_chapters", "num_volumes",
"alternative_titles", "start_date",
"end_date", "mean", "rank",
- "media_type", "status",
+ "media_type", "status", "authors",
}
func MangaSearch(label, searchString string) m.Manga {
mangas := mal.SearchManga(searchString, MangaSearchFields)
+ 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
+ // }
+ // same with genres
+ if len(manga.Genres) > 0 {
+ var genresFormatted string
+ for j, genre := range manga.Genres {
+ genresFormatted = genresFormatted + genre.Name
+ // setting other genre names as ""
+ mangas[i].Genres[j].Name = ""
+ if j != len(manga.Genres) - 1 {
+ genresFormatted = genresFormatted + ", "
+ }
+ }
+ mangas[i].Genres[0].Name = genresFormatted
+ }
+ }
+
template := &p.SelectTemplates {
Label: "{{ . }}",
Active: "{{ .Title | magenta }}",
@@ -143,15 +188,16 @@ func MangaSearch(label, searchString string) m.Manga {
Selected: "{{ .Title | blue }}",
Details: `
--------- {{ .Title }} ----------
-{{ "Number of Volumes:" | blue | bold }} {{ .NumVolumes }}
-{{ "Number of Chapters:" | blue | bold }} {{ .NumChapters }}
-{{ "English Title:" | blue | bold }} {{ .AltTitles.En }}
-{{ "Japanese Title:" | blue | bold }} {{ .AltTitles.Ja }}
-{{ "Original Run:" | blue | bold }} {{ .StartDate }} - {{ .EndDate }}
-{{ "Mean Score:" | blue | bold }} {{ .MeanScore }}
-{{ "Rank:" | blue | bold }} {{ .Rank }}
+{{ "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 }}
+{{ "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 }}
`,
}
diff --git a/ui/ui.go b/ui/ui.go
index 74bf0f3..a54818e 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -18,4 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package ui
-var PromptLength int
+var (
+ PromptLength, SynopsisLength int
+)