Improved import

This commit is contained in:
Eduard Urbach 2018-04-03 22:53:53 +02:00
parent 8f5d98addb
commit 2010e9ed68
5 changed files with 55 additions and 14 deletions

View File

@ -1,6 +1,8 @@
package home
import (
"strings"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/pages/frontpage"
"github.com/animenotifier/notify.moe/utils"
@ -14,5 +16,12 @@ func Get(ctx *aero.Context) string {
return frontpage.Get(ctx)
}
return ctx.Redirect("/+" + user.Nick + "/animelist/watching")
// Redirect
prefix := "/"
if strings.HasPrefix(ctx.URI(), "/_") {
prefix = "/_/"
}
return ctx.Redirect(prefix + "+" + user.Nick + "/animelist/watching")
}

View File

@ -2,6 +2,7 @@ package listimportanilist
import (
"net/http"
"strings"
"github.com/aerogo/aero"
"github.com/animenotifier/anilist"
@ -66,7 +67,14 @@ func Finish(ctx *aero.Context) string {
animeList.Save()
return ctx.Redirect("/+" + user.Nick + "/animelist/watching")
// Redirect
prefix := "/"
if strings.HasPrefix(ctx.URI(), "/_") {
prefix = "/_/"
}
return ctx.Redirect(prefix + "+" + user.Nick + "/animelist/watching")
}
// getMatches finds and returns all matches for the logged in user.

View File

@ -2,6 +2,7 @@ package listimportkitsu
import (
"net/http"
"strings"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
@ -79,7 +80,14 @@ func Finish(ctx *aero.Context) string {
animeList.Save()
return ctx.Redirect("/+" + user.Nick + "/animelist/watching")
// Redirect
prefix := "/"
if strings.HasPrefix(ctx.URI(), "/_") {
prefix = "/_/"
}
return ctx.Redirect(prefix + "+" + user.Nick + "/animelist/watching")
}
// getMatches finds and returns all matches for the logged in user.

View File

@ -3,6 +3,7 @@ package listimportmyanimelist
import (
"net/http"
"strconv"
"strings"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
@ -75,7 +76,14 @@ func Finish(ctx *aero.Context) string {
animeList.Save()
return ctx.Redirect("/+" + user.Nick + "/animelist/watching")
// Redirect
prefix := "/"
if strings.HasPrefix(ctx.URI(), "/_") {
prefix = "/_/"
}
return ctx.Redirect(prefix + "+" + user.Nick + "/animelist/watching")
}
// getMatches finds and returns all matches for the logged in user.

View File

@ -21,7 +21,7 @@ func main() {
continue
}
fmt.Println(anime.Title.Canonical, malID)
fmt.Printf("%s %s\n", color.CyanString(anime.Title.Canonical), malID)
sync(anime, malID)
}
@ -38,37 +38,45 @@ func sync(anime *arn.Anime, malID string) {
malAnime := obj.(*mal.Anime)
if len(anime.Genres) == 0 {
if len(anime.Genres) == 0 && len(malAnime.Genres) > 0 {
fmt.Println("Genres:", malAnime.Genres)
anime.Genres = malAnime.Genres
}
if anime.EpisodeCount == 0 {
if anime.EpisodeCount == 0 && malAnime.EpisodeCount != 0 {
fmt.Println("EpisodeCount:", malAnime.EpisodeCount)
anime.EpisodeCount = malAnime.EpisodeCount
}
if anime.EpisodeLength == 0 {
if anime.EpisodeLength == 0 && malAnime.EpisodeLength != 0 {
fmt.Println("EpisodeLength:", malAnime.EpisodeLength)
anime.EpisodeLength = malAnime.EpisodeLength
}
if anime.StartDate == "" {
if anime.StartDate == "" && malAnime.StartDate != "" {
fmt.Println("StartDate:", malAnime.StartDate)
anime.StartDate = malAnime.StartDate
}
if anime.EndDate == "" {
if anime.EndDate == "" && malAnime.EndDate != "" {
fmt.Println("EndDate:", malAnime.EndDate)
anime.EndDate = malAnime.EndDate
}
if anime.Source == "" {
if anime.Source == "" && malAnime.Source != "" {
fmt.Println("Source:", malAnime.Source)
anime.Source = malAnime.Source
}
if anime.Title.Japanese == "" {
if anime.Title.Japanese == "" && malAnime.JapaneseTitle != "" {
fmt.Println("JapaneseTitle:", malAnime.JapaneseTitle)
anime.Title.Japanese = malAnime.JapaneseTitle
}
if anime.Title.English == "" {
if anime.Title.English == "" && malAnime.EnglishTitle != "" {
fmt.Println("EnglishTitle:", malAnime.EnglishTitle)
anime.Title.English = malAnime.EnglishTitle
}
anime.Save()
// anime.Save()
}