Sonarr version (exact version): 2.0.0.4146
OS: Windows 10
So I used filebot to do all my post processing stuff so I can post process both movies and tv shows instead of just tv shows and plus not have to deal with running various programs to extract shows and well various other reasons as well… anyways what I need help with is the refresh/rescan series command…
$url = "http://localhost:8989/api/command"
$json = "{ ""name"": ""RescanSeries"" }"
Write-Host "Publishing update $version ($branch) to: $url"
Invoke-RestMethod -Uri $url -Method Post -Body $json -Headers @{"X-Api-Key"="(api key)"}
This is currently what I’m running in powershell and it works, but the thing is that it refreshes/rescans every single show I have on sonarr, I don’t want it to do that I just want it to refresh/rescan the series for the show that is going through the post process stuff at the time.
the optional parameter says that I can do the above by putting
seriesId (int)
into the command, but the thing is I can’t seem to figure out where to put it. :s anywhere I put it at throws up an error doing a test run, without it though I can run the test succefully and it’ll refresh/rescan all of my shows on sonarr.
this stuff used to come second nature to me easily but I haven’t messed with powershell and such in a very very long time. So I was wondering if someone could point me into the spot of where the seriesId (int)
should go for this to work and only refresh/rescan the series for the downloaded episode.
I suppose in the json container?
$json = "{ ""name"": ""RescanSeries"", ""seriesId"" : <number> }"
I tried that but it always threw up an error when doing any testing.
Ok, let’s go for plan B
What are you actually trying to achieve, refreshing the series after every download?
Edit: ok, yes, I see… you want to refresh the series in sonarr so it can “see” the new file and mark it as downloaded, rather than wait for the 12 interval.
This space is now reserved for possible solutions
well doing something like
$json = "{ ""name"": ""RescanSeries"", ""seriesId"" : 100 }"
had let me rescan a series without any sorta errors or anything, but that doesn’t solve the exact issue I’m trying to accomplish, what I’m trying to accomplish is have a episode download and the script refresh just that show and not all of them.
what I need it to do is grab the ID of show that I just downloaded the episode for and rescan only that series, and if I download a episode for a different show than for it to rescan for episodes for that show…
I’ve tried
$Json = “{ ““name””: ““RescanSeries””, ““seriesId”” : }”
and
$json = "{ ""name"": ""RescanSeries"", ""seriesId"" : ""{id}"" }"
and
$json = "{ ""name"": ""RescanSeries"", ""seriesId"" : {id} }"
and none of them worked out like I wanted them to, and yea I want it to refresh/rescan the series so sonarr can see it and mark it as downloaded so I don’t have to wait the 12 hour intervals and have it accidently redownload the episode again because of sonarr not doing the post processing but filebot instead.
Sorry, have to ask, it’s nagging at me… why don’t you let sonarr handle postprocessing?
Because sonarr doesn’t have some of the post processing stuff that I want it to do, like downloading subtitles, 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.
I had a groovy script that used to work and do exactly what I’m trying to accomplish right now but filebot recently updated and has some new features I want to take advantage of but in the process it broke the script I was using and the guy who made the script isn’t around to fix it up and such and since I don’t know enough about groovy to fix it myself I have to resort to doing it through powershell now but I’m just stuck on it updating whatever series I downloaded the episode for vs it updating every single series I have on sonarr.
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
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…