From c6893a1679823393c81c42100a114002c5438ffe Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sun, 4 Jun 2017 22:06:14 +0200 Subject: [PATCH] Updated database layout --- jobs/sync-anime/sync-anime.go | 32 ++++++++++++++++++++------------ mixins/AnimeGrid.pixy | 2 +- pages/anime/anime.pixy | 4 ++-- pages/search/search.pixy | 2 +- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/jobs/sync-anime/sync-anime.go b/jobs/sync-anime/sync-anime.go index 1290898b..b664c7fb 100644 --- a/jobs/sync-anime/sync-anime.go +++ b/jobs/sync-anime/sync-anime.go @@ -2,7 +2,6 @@ package main import ( "fmt" - "strconv" "strings" "github.com/animenotifier/arn" @@ -20,23 +19,33 @@ func main() { for anime := range allAnime { sync(anime) } + + println("Finished.") } func sync(data *kitsu.Anime) { anime := arn.Anime{} + attr := data.Attributes - anime.ID, _ = strconv.Atoi(data.ID) - anime.Type = strings.ToLower(data.Attributes.ShowType) - anime.Title.Canonical = data.Attributes.CanonicalTitle - anime.Title.English = data.Attributes.Titles.En - anime.Title.Japanese = data.Attributes.Titles.JaJp - anime.Title.Romaji = data.Attributes.Titles.EnJp - anime.Title.Synonyms = data.Attributes.AbbreviatedTitles - anime.Image = data.Attributes.PosterImage.Original - anime.Summary = arn.FixAnimeDescription(data.Attributes.Synopsis) + anime.ID = data.ID + anime.Type = strings.ToLower(attr.ShowType) + anime.Title.Canonical = attr.CanonicalTitle + anime.Title.English = attr.Titles.En + anime.Title.Japanese = attr.Titles.JaJp + anime.Title.Romaji = attr.Titles.EnJp + anime.Title.Synonyms = attr.AbbreviatedTitles + anime.Image.Tiny = kitsu.FixImageURL(attr.PosterImage.Tiny) + anime.Image.Small = kitsu.FixImageURL(attr.PosterImage.Small) + anime.Image.Large = kitsu.FixImageURL(attr.PosterImage.Large) + anime.Image.Original = kitsu.FixImageURL(attr.PosterImage.Original) + anime.StartDate = attr.StartDate + anime.EndDate = attr.EndDate + anime.EpisodeCount = attr.EpisodeCount + anime.EpisodeLength = attr.EpisodeLength + anime.Summary = arn.FixAnimeDescription(attr.Synopsis) if data.Attributes.YoutubeVideoID != "" { - anime.Trailers = append(anime.Trailers, &arn.AnimeTrailer{ + anime.Trailers = append(anime.Trailers, arn.AnimeTrailer{ Service: "Youtube", VideoID: data.Attributes.YoutubeVideoID, }) @@ -53,5 +62,4 @@ func sync(data *kitsu.Anime) { } fmt.Println(status, anime.ID, anime.Title.Canonical) - } diff --git a/mixins/AnimeGrid.pixy b/mixins/AnimeGrid.pixy index 268e4d17..3ec380d3 100644 --- a/mixins/AnimeGrid.pixy +++ b/mixins/AnimeGrid.pixy @@ -2,4 +2,4 @@ component AnimeGrid(animeList []*arn.Anime) .anime-grid each anime in animeList a.anime-grid-cell.ajax(href="/anime/" + toString(anime.ID)) - img.anime-grid-image(src=anime.Image, alt=anime.Title.Romaji, title=anime.Title.Romaji + " (" + toString(anime.Watching) + ")") \ No newline at end of file + img.anime-grid-image(src=anime.Image, alt=anime.Title.Romaji, title=anime.Title.Romaji + " (" + toString(anime.Watching()) + ")") \ No newline at end of file diff --git a/pages/anime/anime.pixy b/pages/anime/anime.pixy index 911df6a5..384a03f2 100644 --- a/pages/anime/anime.pixy +++ b/pages/anime/anime.pixy @@ -1,8 +1,8 @@ component Anime(anime *arn.Anime) .anime-header(data-id=anime.ID) - if anime.Image != "" + if anime.Image.Small != "" .anime-image-container - img.anime-cover-image(src=anime.Image, alt=anime.Title.Romaji) + img.anime-cover-image(src=anime.Image.Small, alt=anime.Title.Romaji) .space diff --git a/pages/search/search.pixy b/pages/search/search.pixy index d015bb34..dc922971 100644 --- a/pages/search/search.pixy +++ b/pages/search/search.pixy @@ -12,5 +12,5 @@ component Search(popularAnime []*arn.Anime, titleCount int, animeCount int) .popular-anime-list each anime in popularAnime - a.popular-anime.ajax(href="/anime/" + toString(anime.ID), title=anime.Title.Romaji + " (" + arn.Plural(anime.Watching, "user") + " watching)") + a.popular-anime.ajax(href="/anime/" + toString(anime.ID), title=anime.Title.Romaji + " (" + arn.Plural(anime.Watching(), "user") + " watching)") img.anime-image.popular-anime-image(src=anime.Image, alt=anime.Title.Romaji) \ No newline at end of file