vosmiic / jellyfin-ani-sync

Synchronize anime watch status between Jellyfin and anime tracking sites.
GNU General Public License v3.0
250 stars 18 forks source link

NPE during status update with Shikimori provider #110

Closed tie closed 7 months ago

tie commented 7 months ago

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

Additional context

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

https://github.com/vosmiic/jellyfin-ani-sync/blob/de2c88303a6594af8f3acac4f059755e48171d08/Helpers/ClassConversions.cs#L97-L102

https://github.com/vosmiic/jellyfin-ani-sync/blob/de2c88303a6594af8f3acac4f059755e48171d08/UpdateProviderStatus.cs#L341-L347

https://github.com/vosmiic/jellyfin-ani-sync/blob/de2c88303a6594af8f3acac4f059755e48171d08/Models/Shikimori/ShikimoriMedia.cs#L7-L21

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": []
}