diff --git a/jobs/anime-images/anime-images.go b/jobs/anime-images/anime-images.go index 144b7588..a714c7ff 100644 --- a/jobs/anime-images/anime-images.go +++ b/jobs/anime-images/anime-images.go @@ -83,7 +83,7 @@ func work(anime *arn.Anime) error { qualityBonusMedium := 10 qualityBonusSmall := 10 - kitsuOriginal := fmt.Sprintf("https://media.kitsu.io/anime/poster_images/%s/original", anime.ID) + kitsuOriginal := fmt.Sprintf("https://media.kitsu.io/anime/poster_images/%s/original", anime.GetMapping("kitsu/anime")) // Define the input sources sources := []ipo.Input{} diff --git a/pages/editor/kitsu.go b/pages/editor/kitsu.go index b783f11d..c8b83f84 100644 --- a/pages/editor/kitsu.go +++ b/pages/editor/kitsu.go @@ -13,10 +13,10 @@ import ( // NewKitsuAnime ... func NewKitsuAnime(ctx *aero.Context) string { user := utils.GetUser(ctx) + allAnime := arn.AllAnime() animes := arn.FilterKitsuAnime(func(anime *kitsu.Anime) bool { - _, err := arn.GetAnime(anime.ID) - return err != nil + return arn.FindKitsuAnime(anime.ID, allAnime) != nil }) sort.Slice(animes, func(i, j int) bool { diff --git a/patches/generate-anime-ids/generate-anime-ids.go b/patches/generate-anime-ids/generate-anime-ids.go index d8e019f0..1b639a93 100644 --- a/patches/generate-anime-ids/generate-anime-ids.go +++ b/patches/generate-anime-ids/generate-anime-ids.go @@ -16,7 +16,9 @@ func main() { defer color.Green("Finished") defer arn.Node.Close() - allAnime := arn.AllAnime() + allAnime := arn.FilterAnime(func(anime *arn.Anime) bool { + return len(anime.ID) < len("hw5heOmiR") + }) sort.Slice(allAnime, func(i, j int) bool { aID, _ := strconv.Atoi(allAnime[i].ID) diff --git a/patches/import-jikan-characters/import-jikan-characters.go b/patches/import-jikan-characters/import-jikan-characters.go deleted file mode 100644 index 8a4bdc04..00000000 --- a/patches/import-jikan-characters/import-jikan-characters.go +++ /dev/null @@ -1,93 +0,0 @@ -package main - -func main() {} - -// import ( -// "fmt" -// "strings" - -// "github.com/animenotifier/arn" -// "github.com/animenotifier/jikan" -// "github.com/fatih/color" -// ) - -// var jikanDB = arn.Node.Namespace("jikan") - -// func main() { -// color.Yellow("Importing jikan characters...") -// defer arn.Node.Close() - -// for characterObj := range jikanDB.All("Character") { -// jikanCharacter := characterObj.(*jikan.Character) - -// if jikanCharacter.Name != "Slaine Troyard" { -// continue -// } - -// character := &arn.Character{ -// ID: arn.GenerateID("Character"), -// Description: jikanCharacter.About, -// Name: &arn.CharacterName{ -// Romaji: jikanCharacter.Name, -// Japanese: jikanCharacter.NameJapanese, -// }, -// Image: jikanCharacter.Image, -// // Mappings: []*arn.Mapping{ -// // &arn.Mapping{ -// // Service: "myanimelist/character", -// // ServiceID: jikanCharacter. -// // } -// // }, -// } - -// if strings.HasPrefix(character.Name.Japanese, "(") { -// character.Name.Japanese = strings.TrimPrefix(character.Name.Japanese, "(") -// character.Name.Japanese = strings.TrimSuffix(character.Name.Japanese, ")") -// } - -// lines := strings.Split(character.Description, "\n") -// finalLines := make([]string, 0, len(lines)) - -// for _, line := range lines { -// line = strings.TrimSpace(line) -// originalLine := line - -// if strings.HasPrefix(line, "(") { -// line = strings.TrimPrefix(line, "(") -// line = strings.TrimSuffix(line, ")") -// } - -// line = strings.TrimSpace(line) - -// colonPos := strings.Index(line, ":") - -// if colonPos == -1 || colonPos < 2 || colonPos > 25 { -// finalLines = append(finalLines, originalLine) -// continue -// } - -// key := line[:colonPos] -// value := line[colonPos+1:] - -// value = strings.TrimSpace(value) - -// if key == "source" { -// key = "Source" -// } - -// character.Attributes = append(character.Attributes, &arn.CharacterAttribute{ -// Name: key, -// Value: value, -// }) - -// fmt.Println(color.CyanString(key), color.YellowString(value)) -// } - -// character.Description = strings.Join(finalLines, "\n") -// character.Description = strings.TrimSpace(character.Description) - -// arn.PrettyPrint(character) -// } - -// color.Green("Finished.") -// } diff --git a/patches/import-kitsu-mappings/import-kitsu-mappings.go b/patches/import-kitsu-mappings/import-kitsu-mappings.go index e364efcd..0be56971 100644 --- a/patches/import-kitsu-mappings/import-kitsu-mappings.go +++ b/patches/import-kitsu-mappings/import-kitsu-mappings.go @@ -13,6 +13,8 @@ func main() { defer color.Green("Finished.") defer arn.Node.Close() + allAnime := arn.AllAnime() + for mapping := range arn.StreamKitsuMappings() { if mapping.Relationships.Item.Data.Type != "anime" { continue @@ -22,7 +24,7 @@ func main() { continue } - anime, _ := arn.GetAnime(mapping.Relationships.Item.Data.ID) + anime := arn.FindKitsuAnime(mapping.Relationships.Item.Data.ID, allAnime) if anime == nil { continue diff --git a/patches/kitsu-anilist/kitsu-anilist.go b/patches/kitsu-anilist/kitsu-anilist.go index e76428a6..78a00ab7 100644 --- a/patches/kitsu-anilist/kitsu-anilist.go +++ b/patches/kitsu-anilist/kitsu-anilist.go @@ -16,6 +16,8 @@ func main() { added := 0 conflicted := 0 + allAnime := arn.AllAnime() + for mapping := range arn.StreamKitsuMappings() { if mapping.Relationships.Item.Data.Type != "anime" { continue @@ -31,7 +33,7 @@ func main() { externalID = externalID[len("anime/"):] } - anime, _ := arn.GetAnime(mapping.Relationships.Item.Data.ID) + anime := arn.FindKitsuAnime(mapping.Relationships.Item.Data.ID, allAnime) if anime == nil { continue diff --git a/patches/show-kitsu-mappings/show-kitsu-mappings.go b/patches/show-kitsu-mappings/show-kitsu-mappings.go index 0ea0f01f..f01983e6 100644 --- a/patches/show-kitsu-mappings/show-kitsu-mappings.go +++ b/patches/show-kitsu-mappings/show-kitsu-mappings.go @@ -12,7 +12,7 @@ func main() { for mapping := range arn.StreamKitsuMappings() { fmt.Printf( - "Anime %s: %s mapped to %s\n", + "Kitsu Anime %s: %s mapped to %s\n", mapping.Relationships.Item.Data.ID, color.YellowString(mapping.Attributes.ExternalSite), color.GreenString(mapping.Attributes.ExternalID),