mirror of
https://github.com/ultrasn0w/huso.git
synced 2025-12-14 06:19:52 +01:00
MalConvert
This commit is contained in:
43
schaffer.go
43
schaffer.go
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
func JikanConvert(jik *SeasonAnimeJikan) Anime {
|
||||
@@ -47,6 +48,48 @@ func JikanConvert(jik *SeasonAnimeJikan) Anime {
|
||||
return res
|
||||
}
|
||||
|
||||
func MalConvert(mal *AnimeDetailMal) Anime {
|
||||
res := Anime{
|
||||
Anime: mal.ID,
|
||||
Title: mal.Title,
|
||||
TitleEn: mal.AlternativeTitles.En,
|
||||
TitleJp: mal.AlternativeTitles.Ja,
|
||||
ImageMediumURL: mal.MainPicture.Medium,
|
||||
ImageLargeURL: mal.MainPicture.Large,
|
||||
ImageThumbURL: "",
|
||||
Type: mal.MediaType,
|
||||
Status: mal.Status,
|
||||
Episodes: mal.NumEpisodes,
|
||||
Synopsis: mal.Synopsis,
|
||||
Year: mal.StartSeason.Year,
|
||||
Season: mal.StartSeason.Season,
|
||||
Score: mal.Mean,
|
||||
ScoredBy: mal.NumScoringUsers,
|
||||
Rank: mal.Rank,
|
||||
Popularity: mal.Popularity,
|
||||
Members: mal.NumListUsers,
|
||||
Source: mal.Source,
|
||||
DayOfTheWeek: mal.Broadcast.DayOfTheWeek,
|
||||
StartTime: mal.Broadcast.StartTime,
|
||||
TrailerURL: "",
|
||||
}
|
||||
for _, g := range mal.Genres {
|
||||
res.Genres = append(res.Genres, AnimeGenre{
|
||||
ID: g.ID,
|
||||
Name: g.Name,
|
||||
})
|
||||
}
|
||||
for _, s := range mal.Studios {
|
||||
res.Studios = append(res.Studios, AnimeStudio{
|
||||
ID: s.ID,
|
||||
Name: s.Name,
|
||||
})
|
||||
}
|
||||
res.StartDate, _ = time.Parse("2006-01-02", mal.StartDate)
|
||||
res.EndDate, _ = time.Parse("2006-01-02", mal.EndDate)
|
||||
return res
|
||||
}
|
||||
|
||||
func GetSeasonCache() ([]Anime, error) {
|
||||
data, err := cache.Get(seasonApiJikan)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user