From a4a20366f1b61657e1b6a84c1ddf94237eee8bba Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Tue, 6 Nov 2018 14:43:36 +0900 Subject: [PATCH] New MAL importer --- mixins/AnimeListItems.pixy | 5 ++++- .../listimportmyanimelist/myanimelist.go | 20 +++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/mixins/AnimeListItems.pixy b/mixins/AnimeListItems.pixy index cee31332..b5ecb219 100644 --- a/mixins/AnimeListItems.pixy +++ b/mixins/AnimeListItems.pixy @@ -1,6 +1,9 @@ component AnimeListItems(animeListItems []*arn.AnimeListItem, nextIndex int, viewUser *arn.User, user *arn.User) if len(animeListItems) == 0 - p.no-data.mountable= viewUser.Nick + " hasn't added any anime to this list yet." + 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." else .anime-list-container AnimeList(animeListItems, nextIndex, viewUser, user) \ No newline at end of file diff --git a/pages/listimport/listimportmyanimelist/myanimelist.go b/pages/listimport/listimportmyanimelist/myanimelist.go index 7e4cfcc7..b18c10ec 100644 --- a/pages/listimport/listimportmyanimelist/myanimelist.go +++ b/pages/listimport/listimportmyanimelist/myanimelist.go @@ -49,21 +49,19 @@ func Finish(ctx *aero.Context) string { continue } - rating, _ := strconv.ParseFloat(match.MyAnimeListItem.MyScore, 64) - episodesWatched, _ := strconv.Atoi(match.MyAnimeListItem.MyWatchedEpisodes) - rewatchCount, convErr := strconv.Atoi(match.MyAnimeListItem.MyRewatching) + rewatchCount := 0 - if convErr != nil { - rewatchCount = 0 + if match.MyAnimeListItem.IsRewatching { + rewatchCount = 1 } item := &arn.AnimeListItem{ AnimeID: match.ARNAnime.ID, - Status: arn.MyAnimeListStatusToARNStatus(match.MyAnimeListItem.MyStatus), - Episodes: episodesWatched, + Status: arn.MyAnimeListStatusToARNStatus(match.MyAnimeListItem.Status), + Episodes: match.MyAnimeListItem.NumWatchedEpisodes, Notes: "", Rating: arn.AnimeListItemRating{ - Overall: rating, + Overall: float64(match.MyAnimeListItem.Score), }, RewatchCount: rewatchCount, 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. -func findAllMatches(animeList *mal.AnimeList) []*arn.MyAnimeListMatch { +func findAllMatches(animeList mal.AnimeList) []*arn.MyAnimeListMatch { finder := arn.NewAnimeFinder("myanimelist/anime") matches := []*arn.MyAnimeListMatch{} - for _, item := range animeList.Items { + for _, item := range animeList { matches = append(matches, &arn.MyAnimeListMatch{ MyAnimeListItem: item, - ARNAnime: finder.GetAnime(item.AnimeID), + ARNAnime: finder.GetAnime(strconv.Itoa(item.AnimeID)), }) }