Commit 625c335969
Unsigned
Layout: unified · split
internal/anilist.go +6 −2
| @@ -28,7 +28,12 @@ func GetAnimeMap(animeList AnimeList) map[string]string { | |||
| 28 | // Helper function to populate the map from a slice of entries | 28 | // Helper function to populate the map from a slice of entries |
| 29 | populateMap := func(entries []Entry) { | 29 | populateMap := func(entries []Entry) { |
| 30 | for _, entry := range entries { | 30 | for _, entry := range entries { |
| 31 | animeMap[strconv.Itoa(entry.Media.ID)] = entry.Media.Title.English | 31 | // Only include entries with a non-empty English title |
| 32 | if entry.Media.Title.English != "" { | ||
| 33 | animeMap[strconv.Itoa(entry.Media.ID)] = entry.Media.Title.English | ||
| 34 | } else { | ||
| 35 | animeMap[strconv.Itoa(entry.Media.ID)] = entry.Media.Title.Romaji | ||
| 36 | } | ||
| 32 | } | 37 | } |
| 33 | } | 38 | } |
| 34 | 39 | ||
| @@ -41,7 +46,6 @@ func GetAnimeMap(animeList AnimeList) map[string]string { | |||
| 41 | 46 | ||
| 42 | return animeMap | 47 | return animeMap |
| 43 | } | 48 | } |
| 44 | |||
| 45 | // SearchAnimeAnilist sends the query to AniList and returns a map of title to ID | 49 | // SearchAnimeAnilist sends the query to AniList and returns a map of title to ID |
| 46 | func SearchAnimeAnilist(query, token string) (map[string]string, error) { | 50 | func SearchAnimeAnilist(query, token string) (map[string]string, error) { |
| 47 | url := "https://graphql.anilist.co" | 51 | url := "https://graphql.anilist.co" |