ID usage fixes

This commit is contained in:
Eduard Urbach 2018-04-04 14:51:55 +02:00
parent 1bc62ab105
commit a6a71358bf
7 changed files with 13 additions and 100 deletions

View File

@ -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{}

View File

@ -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 {

View File

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

View File

@ -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.")
// }

View File

@ -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

View File

@ -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

View File

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