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,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)

View File

@ -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)),
})
}