everettsouthwick / Eraserr

Python script for deleting unwatched or stale media from Plex servers using Radarr, Sonarr, and Overseerr.
GNU General Public License v3.0
24 stars 1 forks source link

No episodeNumber on sonarr API #30

Closed Merrick28 closed 1 year ago

Merrick28 commented 1 year ago

Describe the bug When starting to delete an episode from a serie :

ONARR :: DRY RUN :: Black Mirror would be unmonitored
Traceback (most recent call last):
  File "/app/eraserr.py", line 34, in <module>
    main(args)
  File "/app/src/main.py", line 25, in main
    job_runner.run()
  File "/app/src/jobs.py", line 23, in run
    self.job()
  File "/app/src/jobs.py", line 44, in job
    total_size = self.fetch_series()
                 ^^^^^^^^^^^^^^^^^^^
  File "/app/src/jobs.py", line 88, in fetch_series
    deleted, size = self.sonarr.find_and_delete_series(tvdb_id)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/sonarr.py", line 116, in find_and_delete_series
    size_on_disk = self.delete_unmonitored_episodes(series)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/sonarr.py", line 196, in delete_unmonitored_episodes
    f"SONARR :: DRY RUN :: {title} S{episode['seasonNumber']:02}E{episode['episodeNumber']:02} would be deleted. {convert_bytes(episode['size'])} would be freed up"
                                                                  ~~~~~~~^^^^^^^^^^^^^^^^^
KeyError: 'episodeNumber'

My version of sonarr :

Version
3.0.10.1567
Package Version
3.0.10.1567-ls199 by [linuxserver.io](https://linuxserver.io/)
Mono Version
6.12.0.199
AppData directory
/config
Startup directory
/app/sonarr/bin
Mode
Console
Uptime

When I launch the api :

  {
    "seriesId": 5,
    "seasonNumber": 6,
    "relativePath": "Season 6/Black Mirror - S06E05 - TFA - Demon 79 WEBDL-1080p.mkv",
    "path": "/home/xxxxxx/seedbox/Medias/Series/Black Mirror/Season 6/Black Mirror - S06E05 - TFA - Demon 79 WEBDL-1080p.mkv",
    "size": 3500312851,
    "dateAdded": "2023-06-15T17:50:49.655063Z",
    "sceneName": "Black.Mirror.S06E05.FiNAL.MULTi.1080p.WEB.DDP5.1.Atmos.x264-TFA",
    "releaseGroup": "TFA",
    "language": {
      "id": 1,
      "name": "English"
    },
    "quality": {
      "quality": {
        "id": 3,
        "name": "WEBDL-1080p",
        "source": "web",
        "resolution": 1080
      },
      "revision": {
        "version": 1,
        "real": 0,
        "isRepack": false
      }
    },
    "mediaInfo": {
      "audioBitrate": 768000,
      "audioChannels": 5.1,
      "audioCodec": "EAC3 Atmos",
      "audioLanguages": "English / French",
      "audioStreamCount": 2,
      "videoBitDepth": 8,
      "videoBitrate": 5000000,
      "videoCodec": "x264",
      "videoFps": 25.0,
      "videoDynamicRange": "",
      "videoDynamicRangeType": "",
      "resolution": "1920x1080",
      "runTime": "1:14:39",
      "scanType": "Progressive",
      "subtitles": "English / French / French"
    },
    "qualityCutoffNotMet": false,
    "languageCutoffNotMet": false,
    "id": 11496
  }

There is no episodeNumber to look for, the container crashes

Suggestion : it is only used for dry run, this information could be removed (the title and the season number may be sufficient ?)

everettsouthwick commented 1 year ago

Thanks for digging into that, I've noticed this bug and haven't had an opportunity to figure out the root cause. I will implement a fix for this.

Merrick28 commented 1 year ago

I'll make a pull request in a few minutes

everettsouthwick commented 1 year ago

Resolved #31