RefreshSeries/RescanSeries command

Hmph still have yet to get this figured out completely…

@Thirrian you still around?

I use the API a lot. Whenever I have a doubt on how it works or how the payload should be written I open the chrome dev console network section and perform in the webui the same task that I want to do with the api. You’ll see the command listed there , right click menu and copy as curl. Paste it and should see the payload.

I am not familiar with powershell the payload looks correct, except for the double-double quotes I use curl is always just double quotes. Sometimes I wrap double-single-double quotes but is just when i need to expand variables in the payload.

Well doing anything like that seems to just give me a bunch of jibberish that I don’t understand at all… Though I think that is mainly because I am probably not doing something correctly as usual… god why can’t this stuff just be easy -.- makes me feel like tossing my computer out of my window and just giving up on everything…

I have a feeling doing it that way won’t exactly get me the way I want to do things anyways, I need the script to pull the ID of the show I downloaded and replace the part of ““seriesid”” to make it refresh only that series but anything I do I can’t get it to work and it just errors out completely…

I have my scripts in bash, I can fetch the series’s id using curl and jq. Let me know if you want I can give you examples. If you want to take the bash route you can fire your commands from a docker container or a Cygwin terminal.

Imo you should let sonarr post process. Extraction of rars should be done at torrent client side, which is the thing that sonarr cannot do at the moment.

like I said above "sonarr doesn't have some of the post processing stuff that I want it to do, like downloading subtitles, automatic unraring zips/rars and such and I download movies a lot as well which sonarr can't exactly post process, but filebot does all this stuff." so I rather use filebot which takes a whole lot of the process away from having to worry about everything, I can do so much more with filebot post processing everything that I cant do with sonarrs post processing…

Honestly I’m about to just give up on everything because I’m barely getting anywhere with anything and its pissing me off so much… I’m tired of downloading more and more crap, which I would have to do if I went the cygwin or docker way and even then I’d probably be lost on everything again and would take days upon days to get nowhere like I am currently…

I already have my script being able to rescan series, but it rescans every single show that I have on sonarr instead of whatever show is going through the post process at the time.

I just tested in a W7 VM, had to upgrade PS to 4.0 for support of Invoke.

This payload works fine

"{ ""name"": ""RescanSeries"", ""seriesId"": 13 }"

I changed this

@{"X-Api-Key"="(5215023779d84ad391719fc703bba5ba)"}

to

@{"X-Api-Key"="5215023779d84ad391719fc703bba5ba"}

In this example this is how I would get the seriesId using sonarr api using bash with curl and jq

curl -s http://10.10.10.11:8989/api/series -H 'X-Api-Key: 5215023779d84ad391719fc703bba5ba' --compressed | jq -rs '.[]| .[] | select(.title=="Fargo") | .id '

If the name Fargo is a variable then it would be like this

seriesName="Fargo"
then the command

curl -s http://10.10.10.11:8989/api/series -H 'X-Api-Key: 5215023779d84ad391719fc703bba5ba' --compressed | jq -rs --arg seriestitle $seriesName '.[]| .[] | select(.title == $seriestitle ) | .id'

I also download subtitles but in my experience is unlikely there will be any available immediately after sonarr grabs and imports the episode (if the episode was just released). I use subliminal as a scheduled task to automatically download subtitles.
My rars are unpacked by the torrent client and sonarr using CDH has no issue importing them as long as the video unpacked file is in the same directory. The sonarr postprocessing script facility cleans the extracted video file to not have double files when the torrent is removed.

Well I broke down and installed curl and jq but now I’m getting a whole new error trying to run the above…

running

curl -s http://localhost:8989/api/series -H ‘X-Api-Key: 6e7bff2e25e24317924907b16e6b7eee’ --compressed | jq -rs '.[]| .[] | select(.title==“Fargo”) | .id ’

or

curl -s http://localhost:8989/api/series -H ‘X-Api-Key: 6e7bff2e25e24317924907b16e6b7eee’ --compressed | jq -rs --arg seriestitle $seriesName ‘.[]| .[] | select(.title == $seriestitle ) | .id’

just end up throwing up error

‘.[]’ is not recognized as an internal or external command,
operable program or batch file.

Is that bash or cmd?
Does the command jq works by just running it?

was cmd didn’t notice it was for bash, just woke up so still kinda hazy…

yea just typing jq into cmd gives me the whole

    jq - commandline JSON processor [version 1.5]
    Usage: jq [options] <jq filter> [file...]

    jq is a tool for processing JSON inputs, applying the
    given filter to its JSON text inputs and producing the
    filter's results as JSON on standard output.
    The simplest filter is ., which is the identity filter,
    copying jq's input to its output unmodified (except for
    formatting).
    For more advanced filters see the jq(1) manpage ("man jq")
    and/or https://stedolan.github.io/jq

    Some of the options include:
     -c             compact instead of pretty-printed output;
     -n             use `null` as the single input value;
     -e             set the exit status code based on the output;
     -s             read (slurp) all inputs into an array; apply filter to it;
     -r             output raw strings, not JSON texts;
     -R             read raw strings, not JSON texts;
     -C             colorize JSON;
     -M             monochrome (don't colorize JSON);
     -S             sort keys of objects on output;
     --tab  use tabs for indentation;
     --arg a v      set variable $a to value <v>;
     --argjson a v  set variable $a to JSON value <v>;
     --slurpfile a f        set variable $a to an array of JSON texts read from <f>;
    See the manpage for more options.

stuff.

Windows cmd (or curl in windows don’t know really) doesn’t like single quotes so it should be

curl -s http://localhost:8989/api/series -H "X-Api-Key:  6e7bff2e25e24317924907b16e6b7eee" --compressed | jq -rs ".[]| .[] | select(.title==\"Fargo\") | .id "

Using a variable in windows is like

SET seriesName=Fargo

Calling it then in jq should be

curl -s http://localhost:8989/api/series -H "X-Api-Key:  6e7bff2e25e24317924907b16e6b7eee" --compressed | jq -rs --arg seriesTitle %seriesName% ".[]| .[]| select(.title==$seriesTitle) | .id"

okay well that fixed that part but now what if I get

curl: option --compressed: the installed libcurl version doesn’t support this
curl: try ‘curl --help’ or ‘curl --manual’ for more information

even though I am on the latest version of curl.

the location I got curl was from here - http://winampplugins.co.uk/curl/ – curl 7.48.0 - 64-bit

Well take it out then…

but that’s what I’m using for curl… if I take it out curl won’t work xD and I mean that all there is is curl and a certificate, nothing more nothing less, so there really isn’t much else to take out…

I meant take out “–compressed” the option is not supported apparently in that curl binary you have

oh haha woops… okay well that worked, running command

curl -s http://localhost:8989/api/series -H “X-Api-Key: 6e7bff2e25e24317924907b16e6b7eee” | jq -rs ".[]| .[] | select(.title==“Ascension”) | .id "

Ended up producing “79” which is the ID for Ascension in my sonarr list.

now I just need to make the below actually rescan the series whenever it is initiated.

curl -s http://localhost:8989/api/series -H “X-Api-Key: 6e7bff2e25e24317924907b16e6b7eee” | jq -rs --arg seriesTitle %seriesName% “.[]| .[]| select(.title==$seriesTitle) | .id”

The answer is already in this thread, the payload was correct, just escape the double quotes

"{\"name\":\"rescanSeries\",\"seriesId\":110}"

Off to bed now…

Well I must be a total idiot then because I still can’t get it to do anything no matter where I put it at in the curl command…

and wouldn’t having it just refresh 110 only make it refresh that one and only show instead of having it grab the id and replacing that part…

maybe your running like 2-3-4 seperate curl commands, I dont even completely understand, this crap is just annoying… I don’t even know why the hell I use sonarr if all I’ve been doing for the past week now is jumping through hoops trying to get stuff to work so I dont have to use the lousy post processing of sonarr… -.-

EDIT: meh forget it, I’m done trying to figure this crap out… It’s annoyed me to the last bit of annoyance that I can handle, everything just sucks.

I also use filebot instead of the Sonarr feature to deal with my file (because I also download movies without Sonarr and I want those files also to me managed properly).

But I just disable CDH feature and everything works like a charm (Sonarr doesn’t download the same file twice even if it appears in the software as available only after the 12 hours delay). Something must prevent Sonarr from downloading a file twice even if not seen as available.

What more do you need ?

Of course you have to run several curl commands (two) to get to the refresh series folder.

For example Filebot should identify the name of the series, passing that series name in the form of a variable to the script to fetch sonarr information.

SeriesName -> SonarrAPI -> seriesID ##this should be one curl command

RescanSeries+seriesID ->SonarrAPI ##this would be another curl command

I am not a frequent user of windows, but just a quick look on how to define a variable with the command output in cmd is just insane.

for /f "delims=" %%a in ('command') do @set foobar=%%a

There might be another easy way probably in powershell, maybe an advanced windows user can enlighten

That’s is why I prefer bash
In your case i would do something like this.

#!/bin/bash

seriesID=$(curl -s http://10.10.10.11:8989/api/series -H 'X-Api-Key: 5215023779d84ad391719fc703bba5ba' --compressed | jq -rs --arg seriestitle $seriesName '.[]| .[] | select(.title == $seriestitle ) | .id')

curl -s  http://10.10.10.11:8989/api/command -H 'X-Api-Key: 5215023779d84ad391719fc703bba5ba' --data-binary '{ "name": "rescanSeries", "seriesId" : "'$seriesID'" }'

In here were are assuming seriesName is some sort of environment variable defined by filebot that can pass to the script. I have no idea if filebot can do that.

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