package dataimport import ( "fmt" "strings" "fagott.pw/goanilist" "fagott.pw/grilist/models" ) func ConvertGrilAnilist(char *goanilist.CharacterPageResult) *ImporterGril { gril := &ImporterGril{} gril.ID = char.ID gril.KanjiName = char.JapaneseName gril.RomajiName = strings.TrimSpace(fmt.Sprintf("%s %s", char.GivenName, char.FamilyName)) gril.Order = char.Order if char.AlternativeName != "" { gril.OtherNames = append(gril.OtherNames, char.AlternativeName) } if char.ImageURL != "" { gril.Images = append(gril.Images, Image{ Type: ImageTypeFull, URL: char.ImageURL, }) } if char.ThumbURL != "" { gril.Images = append(gril.Images, Image{ Type: ImageTypeThumbnail, URL: char.ThumbURL, }) } for _, anime := range char.Anime { gril.Series = append(gril.Series, ConvertSeriesAnilist(anime.SeriesResult)) } for _, manga := range char.Manga { gril.Series = append(gril.Series, ConvertSeriesAnilist(manga.SeriesResult)) } return gril } func ConvertSeriesTypeAnilist(seriesType string) models.SeriesType { switch seriesType { } return models.SeriesTypeUnknown } func ConvertSeriesAnilist(series goanilist.SeriesResult) models.Series { return models.Series{ ID: series.ID, Type: ConvertSeriesTypeAnilist(series.Type), Name: series.TitleEnglish, KanjiName: series.TitleJapanese, RomajiName: series.TitleRomaji, OtherNames: series.Synonyms, } }