handle_starr_data expects all seasons to have a statistics key
Error:
Traceback (most recent call last):
File "/home/ronald/userScripts/modules/poster_renamerr.py", line 642, in main
results = handle_starr_data(app, server_name, instance_type, include_episode=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ronald/userScripts/util/utility.py", line 574, in handle_starr_data
'season_pack': season['statistics']['episodeCount'] == season['statistics']['totalEpisodeCount'],
~~~~~~^^^^^^^^^^^^^^
KeyError: 'statistics'
Looks like this section of code causes it: https://github.com/Drazzilb08/daps/blob/c86f81fec8c3974b2ced1c768e270186c0dbb814/util/utility.py#L571-L577
I did some fairly basic debugging on my end (since my Python is not so great) to make it print out the season_data for each series it iterates over in the Sonarr instance which is causing the above error.
Mysterious Disappearances
{'nextAiring': '2024-05-08T13:30:00Z', 'previousAiring': '2024-05-01T13:30:00Z', 'episodeFileCount': 4, 'episodeCount': 4, 'totalEpisodeCount': 12, 'sizeOnDisk': 5784786625, 'releaseGroups
--------
Stardust Telepath
{'episodeFileCount': 0, 'episodeCount': 0, 'totalEpisodeCount': 12, 'sizeOnDisk': 0, 'releaseGroups': [], 'percentOfEpisodes': 0}
--------
BARTENDER: Glass of God
{'episodeFileCount': 0, 'episodeCount': 0, 'totalEpisodeCount': 12, 'sizeOnDisk': 0, 'releaseGroups': [], 'percentOfEpisodes': 0}
--------
Kamichu!
None
{'episodeFileCount': 16, 'episodeCount': 16, 'totalEpisodeCount': 16, 'sizeOnDisk': 9769174000, 'releaseGroups': ['Judgment'], 'percentOfEpisodes': 100}
In my case one of the series causing an error seems to be Kamichu! which seems to be lacking a statisctics key for Season 0 (Specials).
I can see that this series has an entry for Specials but no episodes in there, so a bit of an edge case.
No clue how to update the code elegantly to handle this, maybe by using dict.get instead of just grabbing the statistics key? In my debugging modifications this got it to print out None instead of getting a KeyError
Okay. It need a try statement so it doesn't die on that. I'll get to that when I get back from holiday.
Updated dev branch, can you please test this to see if this is fixed.
Just pulled the dev docker image down, getting a slightly different error:
Finished running sync_gdrive
An error occurred:
Traceback (most recent call last):
File "/app/modules/poster_renamerr.py", line 642, in main
results = handle_starr_data(app, server_name, instance_type, include_episode=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/util/utility.py", line 580, in handle_starr_data
'season_has_episodes': season['statistics']['episodeCount'] > 0,
~~~~~~^^^^^^^^^^^^^^
KeyError: 'statistics'
https://github.com/Drazzilb08/daps/commit/8b90f7394501e83209cacb13251aa72e35761fd7#diff-67b18f147213369955c00b435674927a17a57eb8e897cc69a9fa20b19a613ebfR580 I think this line might be the culprit?
In any case, thanks for taking a look!
I think you're 100% correct, please update and try again. Lemme know if the error persists.
Looks good now, I can see kometa setting up posters for shows in that sonarr instance.
Thanks for the help!
No worries. Glad this is fixed. Closing the issue.