linaspurinis / mdblistarr

Companion app for mdblist.com for Radarr and Sonarr integration
20 stars 1 forks source link

Error when Sonarr season doesn't have statistics #4

Open alex-joyce opened 2 months ago

alex-joyce commented 2 months ago

I'm getting an error when mdblistarr is updating my Sonarr records.

Error: Traceback (most recent call last): File "/usr/src/app/mdblistrr/cron.py", line 65, in post_sonarr_payload if season['statistics']['percentOfEpisodes'] == 100: KeyError: 'statistics'

Looks like the issue is occuring when running mdblistarr/mdblistrr/cron.py post_sonarr_payload():

            if show.get('seasons'):
                for season in show['seasons']:
                    if season['statistics']['percentOfEpisodes'] == 100:
                        # At least one season is downloaded 100%
                        exists = True

Not sure why, but there could be cases where a season doesn't have statistics populated as retrieving show['seasons'] did not error.

Probably needs to use .get('statistics'), or wrap it in a try/except block?

alex-joyce commented 2 months ago

Created pull request #5