Need some help with changes in v4 api commands

Version 4.0.0.741
Package Version 4.0.0.741 by linuxserver.io
.NET Yes (6.0.13)
Docker Yes
Database Sqlite 3.44.2

I have a utility on my system that allows me to detect when I delete an episode after I watch it and it then automatically tells Sonarr to rescan that particular series so Sonarr flips the monitored status for the episode off. With the upgrade to V4 as of last night I have had to tweak the API URLs slightly by adding the “v3” string to the API endpoint URL. It seems to be working fine for the series lookup to get the series ID but the actual RescanSeries command does not appear to do anything anymore. It doesn’t appear that there is documentation yet for the API commands so is there anyone out there who would know what has been changed in v4?

This is the lookup command that translates the file system path to a series id and it is working fine in v4…

serid=$(curl -sS http://192.168.1.50:8989/api/v3/series?get --header "X-Api-Key:XXXXXXXXXX" --compressed| /home/linuxbrew/.linuxbrew/bin/jq -rs '.[]| .[] | select(.path=="'"$entries"'") | .id ')

This command appears to do nothing though…

curl http://192.168.1.50:8989/api/v3/command -X POST -d '{"name": "RescanSeries" , "seriesId": "'"$serid"'"}' --header "X-Api-Key:XXXXXXXXXX"

Is there a need for this? The settings Unmonitor Deleted Episodes and Rescan Series Folder after Refresh would seem to cover this functionality.

The interval on the series refresh is 12 hours and I was running into situations where I would watch a 720p version of an episode because I was impatient and then the 1080p version would get pulled down after I deleted it because Sonarr didn’t see the delete. Initially, back in the NZBDrone days this period was much shorter and it wasn’t an issue but once it went to 12 hours I started having this occur more and more.

I wrote a cron utility to manage it for me and have been using it for at least 6 or 7 years to get the exact behaviour I wanted. Just need to know what the new API command is (assuming that functionality is still available in the API).

It took me a while but was finally able to get it figured out. I ended up changing the curl command to explicitly identify the payload as json and then also handle the seriesId as an integer and that solved it so there were definitely some changes to the code for posting API “commands”.

If anyone wants to use this as a reference here is the updated command…

curl -X POST http://192.168.1.50:8989/api/v3/command --header "X-Api-Key:XXXXXXXXXXX" -H 'Content-Type: application/json' -d '{"name":"RescanSeries","seriesId":'$serid'}'
1 Like

What mechanism are you using to do this?

Thanks for this.

I had been using something similar with v3:
curl http://sonarr:8989/api/command -X POST -d '{"name": "RescanSeries"}' --header "X-Api-Key:XXXXXXXXXX"

And your post helped me make a similar adjustment to get it working with v4:
curl http://sonarr:8989/api/v3/command -X POST -H 'Content-Type: application/json' -d '{"name":"RescanSeries"}' --header "X-Api-Key:XXXXXXXXXX"

I am running a 21 data + 3 parity setup using Greyhole as my pooling software (I also run SnapRAID for data protection). Greyhole exposes the pool through Samba utilizing a custom library that they attach to it. Greyhole gives me the ability to have Trash protection on delete as well as logging all operations including file deletes. My utility scans the Greyhole logs and looks for files that were deleted since the last time it scanned the log. It then translates the file path of the delete to a series ID which allows me to trigger a rescan of just the one series that is impacted. I run the utility as a cron job every 10 minutes which means that is the longest my system will go without notifying Sonarr of a delete operation.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.