Updated database layout

This commit is contained in:
Eduard Urbach 2017-06-04 22:06:14 +02:00
parent dac19952db
commit c6893a1679
4 changed files with 24 additions and 16 deletions

View File

@ -2,7 +2,6 @@ package main
import ( import (
"fmt" "fmt"
"strconv"
"strings" "strings"
"github.com/animenotifier/arn" "github.com/animenotifier/arn"
@ -20,23 +19,33 @@ func main() {
for anime := range allAnime { for anime := range allAnime {
sync(anime) sync(anime)
} }
println("Finished.")
} }
func sync(data *kitsu.Anime) { func sync(data *kitsu.Anime) {
anime := arn.Anime{} anime := arn.Anime{}
attr := data.Attributes
anime.ID, _ = strconv.Atoi(data.ID) anime.ID = data.ID
anime.Type = strings.ToLower(data.Attributes.ShowType) anime.Type = strings.ToLower(attr.ShowType)
anime.Title.Canonical = data.Attributes.CanonicalTitle anime.Title.Canonical = attr.CanonicalTitle
anime.Title.English = data.Attributes.Titles.En anime.Title.English = attr.Titles.En
anime.Title.Japanese = data.Attributes.Titles.JaJp anime.Title.Japanese = attr.Titles.JaJp
anime.Title.Romaji = data.Attributes.Titles.EnJp anime.Title.Romaji = attr.Titles.EnJp
anime.Title.Synonyms = data.Attributes.AbbreviatedTitles anime.Title.Synonyms = attr.AbbreviatedTitles
anime.Image = data.Attributes.PosterImage.Original anime.Image.Tiny = kitsu.FixImageURL(attr.PosterImage.Tiny)
anime.Summary = arn.FixAnimeDescription(data.Attributes.Synopsis) 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 != "" { if data.Attributes.YoutubeVideoID != "" {
anime.Trailers = append(anime.Trailers, &arn.AnimeTrailer{ anime.Trailers = append(anime.Trailers, arn.AnimeTrailer{
Service: "Youtube", Service: "Youtube",
VideoID: data.Attributes.YoutubeVideoID, VideoID: data.Attributes.YoutubeVideoID,
}) })
@ -53,5 +62,4 @@ func sync(data *kitsu.Anime) {
} }
fmt.Println(status, anime.ID, anime.Title.Canonical) fmt.Println(status, anime.ID, anime.Title.Canonical)
} }

View File

@ -2,4 +2,4 @@ component AnimeGrid(animeList []*arn.Anime)
.anime-grid .anime-grid
each anime in animeList each anime in animeList
a.anime-grid-cell.ajax(href="/anime/" + toString(anime.ID)) 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) + ")") img.anime-grid-image(src=anime.Image, alt=anime.Title.Romaji, title=anime.Title.Romaji + " (" + toString(anime.Watching()) + ")")

View File

@ -1,8 +1,8 @@
component Anime(anime *arn.Anime) component Anime(anime *arn.Anime)
.anime-header(data-id=anime.ID) .anime-header(data-id=anime.ID)
if anime.Image != "" if anime.Image.Small != ""
.anime-image-container .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 .space

View File

@ -12,5 +12,5 @@ component Search(popularAnime []*arn.Anime, titleCount int, animeCount int)
.popular-anime-list .popular-anime-list
each anime in popularAnime 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) img.anime-image.popular-anime-image(src=anime.Image, alt=anime.Title.Romaji)