New MAL importer

This commit is contained in:
Eduard Urbach 2018-11-06 14:43:36 +09:00
parent 40742745b1
commit a4a20366f1
2 changed files with 13 additions and 12 deletions

View File

@ -1,5 +1,8 @@
component AnimeListItems(animeListItems []*arn.AnimeListItem, nextIndex int, viewUser *arn.User, user *arn.User) component AnimeListItems(animeListItems []*arn.AnimeListItem, nextIndex int, viewUser *arn.User, user *arn.User)
if len(animeListItems) == 0 if len(animeListItems) == 0
if user != nil && user.ID == viewUser.ID
p.no-data.mountable= "You haven't added any anime to this list yet."
else
p.no-data.mountable= viewUser.Nick + " hasn't added any anime to this list yet." p.no-data.mountable= viewUser.Nick + " hasn't added any anime to this list yet."
else else
.anime-list-container .anime-list-container

View File

@ -49,21 +49,19 @@ func Finish(ctx *aero.Context) string {
continue continue
} }
rating, _ := strconv.ParseFloat(match.MyAnimeListItem.MyScore, 64) rewatchCount := 0
episodesWatched, _ := strconv.Atoi(match.MyAnimeListItem.MyWatchedEpisodes)
rewatchCount, convErr := strconv.Atoi(match.MyAnimeListItem.MyRewatching)
if convErr != nil { if match.MyAnimeListItem.IsRewatching {
rewatchCount = 0 rewatchCount = 1
} }
item := &arn.AnimeListItem{ item := &arn.AnimeListItem{
AnimeID: match.ARNAnime.ID, AnimeID: match.ARNAnime.ID,
Status: arn.MyAnimeListStatusToARNStatus(match.MyAnimeListItem.MyStatus), Status: arn.MyAnimeListStatusToARNStatus(match.MyAnimeListItem.Status),
Episodes: episodesWatched, Episodes: match.MyAnimeListItem.NumWatchedEpisodes,
Notes: "", Notes: "",
Rating: arn.AnimeListItemRating{ Rating: arn.AnimeListItemRating{
Overall: rating, Overall: float64(match.MyAnimeListItem.Score),
}, },
RewatchCount: rewatchCount, RewatchCount: rewatchCount,
Created: arn.DateTimeUTC(), Created: arn.DateTimeUTC(),
@ -98,14 +96,14 @@ func getMatches(ctx *aero.Context) ([]*arn.MyAnimeListMatch, string) {
} }
// findAllMatches returns all matches for the anime inside an anilist anime list. // findAllMatches returns all matches for the anime inside an anilist anime list.
func findAllMatches(animeList *mal.AnimeList) []*arn.MyAnimeListMatch { func findAllMatches(animeList mal.AnimeList) []*arn.MyAnimeListMatch {
finder := arn.NewAnimeFinder("myanimelist/anime") finder := arn.NewAnimeFinder("myanimelist/anime")
matches := []*arn.MyAnimeListMatch{} matches := []*arn.MyAnimeListMatch{}
for _, item := range animeList.Items { for _, item := range animeList {
matches = append(matches, &arn.MyAnimeListMatch{ matches = append(matches, &arn.MyAnimeListMatch{
MyAnimeListItem: item, MyAnimeListItem: item,
ARNAnime: finder.GetAnime(item.AnimeID), ARNAnime: finder.GetAnime(strconv.Itoa(item.AnimeID)),
}) })
} }