Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE during status update with Shikimori provider #110

Closed
tie opened this issue Mar 3, 2024 · 0 comments · Fixed by #111
Closed

NPE during status update with Shikimori provider #110

tie opened this issue Mar 3, 2024 · 0 comments · Fixed by #111

Comments

@tie
Copy link
Contributor

tie commented Mar 3, 2024

Describe the bug

NPE during status update with Shikimori provider.

Logs

[2024-03-03 22:00:13.766 +03:00] [INF] [149] jellyfin_ani_sync.UpdateProviderStatus: (Tvdb) Anime reference found in anime list XML
[2024-03-03 22:00:13.766 +03:00] [INF] [149] jellyfin_ani_sync.UpdateProviderStatus: Retrieving provider IDs from offline database...
[2024-03-03 22:00:14.466 +03:00] [INF] [208] jellyfin_ani_sync.UpdateProviderStatus: Retrieved provider IDs
[2024-03-03 22:00:14.466 +03:00] [INF] [208] jellyfin_ani_sync.UpdateProviderStatus: Using provider Shikimori...
[2024-03-03 22:00:28.544 +03:00] [ERR] [208] jellyfin_ani_sync.SessionServerEntry: Fatal error occured during anime sync job: System.NullReferenceException: Object reference not set to an instance of an object.
   at jellyfin_ani_sync.UpdateProviderStatus.TitleCheck(Anime anime, Episode episode, Movie movie)
   at jellyfin_ani_sync.UpdateProviderStatus.Update(BaseItem e, Guid userId, Boolean playedToCompletion)
   at jellyfin_ani_sync.SessionServerEntry.PlaybackStopped(Object sender, PlaybackStopEventArgs e)

To Reproduce

n/a

Expected behavior

The plugin successfully updates progress via Shikimori API.

Screenshots

n/a

Desktop (please complete the following information):

  • Browser n/a
  • Jellyfin version 10.8.13
  • Plugin version 3.0

Additional context

I’d assume that is because Anime instance is not fully initialized from the available Shikimori data,

public static Anime ConvertShikimoriAnime(ShikimoriMedia shikimoriAnime) =>
new() {
Id = shikimoriAnime.Id,
Title = shikimoriAnime.Name,
NumEpisodes = shikimoriAnime.Episodes
};

private bool TitleCheck(Anime anime, Episode episode, Movie movie) {
var title = _animeType == typeof(Episode) ? episode.SeriesName : movie.Name;
return CompareStrings(anime.Title, title) ||
CompareStrings(anime.AlternativeTitles.En, title) ||
(anime.AlternativeTitles.Ja != null && CompareStrings(anime.AlternativeTitles.Ja, title)) ||
(anime.AlternativeTitles.Synonyms != null && anime.AlternativeTitles.Synonyms.Any(synonym => CompareStrings(synonym, title)));
}

public class ShikimoriMedia {
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("name")]
public string? Name { get; set; }
[JsonPropertyName("episodes")]
public int Episodes { get; set; }
[JsonPropertyName("episodes_aired")]
public int EpisodesAired { get; set; }
[JsonPropertyName("synonyms")] public List<string> RelatedAnime { get; set; } = new();
[JsonPropertyName("english")]
public List<string>? English { get; set; }
[JsonPropertyName("japanese")]
public List<string>? Japanese { get; set; }
}

Here is a response from https://shikimori.one/api/animes/52299 with most of the fields omitted except for those that should be used for title check:

{
  "id": 52299,
  "myanimelist_id": 52299,
  "name": "Ore dake Level Up na Ken",
  "russian": "Поднятие уровня в одиночку",
  "english": [ "Solo Leveling" ],
  "japanese": [ "俺 だ け レ ベ ル ア ッ プ な 件 " ],
  "synonyms": [
    "I Level Up Alone",
    "Na Honjaman Level Up"
  ]
}

Also note that strings may be null, e.g. https://shikimori.one/api/animes/54873

{
  "id": 54873,
  "myanimelist_id": 54873,
  "name": "Takoru TV",
  "russian": "Такору",
  "english": [
    null
  ],
  "japanese": [
    "た こ る TV"
  ],
  "synonyms": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant