Help with custom script and API

I am trying to make a custom script and right now I am trying to figure out exactly what Sonarr can do and what it can’t. I have my system set up to download web-dls and then blu-rays. However, I prefer DIMENSION HDTV to web-dl but won’t bother with any other HDTV releases. The problem is there isn’t any automated way baked in to Sonarr to prioritize one quality over another iff it meets a certain condition.

I am trying to use a custom script to accomplish this. It’s not a problem to have a custom script check the release group but if it matches a preset value, how can I get the script to tell Sonarr to download something else? I can get some of the API commands to work but others not without examples of the API calls.

One issue I see is we don’t specify the EpisodeIDs that a file is for when calling the custom script (at least at the moment), so you need to do it in a round-about way.

All API endpoints are under /api, for Sonarr running on the local machine is available at http://localhost:8989 so the API URL is http://localhost:8989/api

  1. Get all episodes for the series: https://github.com/Sonarr/Sonarr/wiki/episode#get (http://localhost:8989/api/episode?seriesId=1&apiKey=your_api_key) (set the series ID to the proper ID)
  2. Find the episodes with the matching Episode File ID (as passed to the script)
  3. Update each episode by setting monitored to false and using a PUT request to update Sonarr: https://github.com/Sonarr/Sonarr/wiki/episode#put

You can use Chrome’s dev tools (Network Tab) to see how the UI sets the JSON and sends it to the server.

Thanks, that helps. I was really having trouble with some of the commands but using a program called Fiddler allowed me to capture API calls made when I would manually click in the webui. That provides me with plenty of examples for some of the more difficult ones.

One last thing. I cannot use the “on grab” setting which is essential for my script. I found out it has not been implemented yet. Is there some idea of when it will be?

It mostly comes down on what information we want to include for on grab, I’ll add some basic options and we can go from there.

1 Like

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