clinton-hall / nzbToMedia

Provides NZB and Torrent postprocessing To CouchPotatoServer, SickBeard/SickRage, HeadPhones, Mylar and Gamez
GNU General Public License v3.0
674 stars 176 forks source link

Sonarr v4 beta status 405/415 #1908

Closed maitikeisi closed 1 year ago

maitikeisi commented 1 year ago

Describe the bug Upgraded to Sonarr v4 (beta) (exact current build: 4.0.0.200) and started getting error 405/415 when post processing files

Technical Specs

  1. Ubuntu 22.04
  2. Python 3.11
  3. NZBget
  4. Sonarr

Expected behavior Expected behavior is that Sonarr successfully detects the incoming file that was successfully downloaded and moved to the correct destination folder.

Log 2022-11-29 16:42:17 POSTPROCESS::NZBDRONE: SUCCESS: The download succeeded, sending a post-process request 2022-11-29 16:39:20 DEBUG ::NZBDRONE: path: /opt/nzbget/unsorted/REMOVED 2022-11-29 16:39:20 DEBUG ::NZBDRONE: Opening URL: http://localhost:8082/api/command with data: {"name": "DownloadedEpisodesScan", "path": "/opt/nzbget/unsorted/REMOVED", "downloadClientId": "xxx", "importMode": "Move"} 2022-11-29 16:39:20 ERROR ::NZBDRONE: Server returned status 405

To get it to work I first changed core/auto_process/tv.py to sonarr api calls to include v3:

        url = '{0}{1}:{2}{3}/api/v3/command'.format(protocol, host, port, web_root)
        url2 = '{0}{1}:{2}{3}/api/v3/config/downloadClient'.format(protocol, host, port, web_root)

after that change the error output was 415: 2022-11-29 16:43:35 POSTPROCESS::NZBDRONE: SUCCESS: The download succeeded, sending a post-process request 2022-11-29 16:43:35 DEBUG ::NZBDRONE: path: /opt/nzbget/unsorted/REMOVED 2022-11-29 16:43:35 DEBUG ::NZBDRONE: Opening URL: http://localhost:8082/api/v3/command with data: {"name": "DownloadedEpisodesScan", "path": "/opt/nzbget/unsorted/REMOVED", "downloadClientId": "xxx", "importMode": "Move"} 2022-11-29 16:43:36 ERROR ::NZBDRONE: Server returned status 415

one more edit to add application/json to headers and it works::

        url = '{0}{1}:{2}{3}/api/v3/command'.format(protocol, host, port, web_root)
        url2 = '{0}{1}:{2}{3}/api/v3/config/downloadClient'.format(protocol, host, port, web_root)
        headers = {'X-Api-Key': apikey, "Content-Type": "application/json"}

2022-11-29 16:47:52 DEBUG ::NZBDRONE: path: /opt/nzbget/unsorted/REMOVED 2022-11-29 16:47:52 DEBUG ::NZBDRONE: Opening URL: http://localhost:8082/api/v3/command with data: {"name": "DownloadedEpisodesScan", "path": "/opt/nzbget/unsorted/REMOVED/REMOVED", "downloadClientId": "xxx", "importMode": "Move"} 2022-11-29 16:47:52 DEBUG ::NZBDRONE: Scan started with id: 6211618 2022-11-29 16:48:12 DEBUG ::NZBDRONE: The Scan command return status: completed 2022-11-29 16:48:12 DEBUG ::NZBDRONE: The directory /opt/nzbget/unsorted/REMOVED has been removed. Renaming was successful. 2022-11-29 16:48:12 INFO ::MAIN: The /opt/nzbget/scripts/nzbToMedia/nzbToNzbDrone.py script completed successfully.

Looks like the API has had some changes, similar to radarr v4 (https://github.com/clinton-hall/nzbToMedia/issues/1862). Not sure if the edits break compatibility with sonarr v3 or not as I didn't test edits with v3. (or if there is better way to fix post processing)

brianredbeard commented 1 year ago

FYI, this change was added in d0b555c251dd1a33bec7c3a16ef523cea6b32460. Just waiting for that to get merged into the master branch (currently it's only in the Sonar-apiv3 branch.

clinton-hall commented 1 year ago

now in master branch