Alright, I am trying just to test this right now and everytime I am sending a call from cmd I get an error regarding the “path” I provided.
I am using this command:
curl.exe -s http://localhost:8989/api/command -X POST -d ‘{"name": "downloadedepisodesscan", "path": "C:\some_path"}’ --header "X-Api-Key:xxxx"
What I get is:
{
"message": "Unexpected character encountered while parsing value: �. Path '', line 0, position 0. (Json snippet '<--error-->�{name:')",
"description": "Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: �. Path '', line 0, position 0. (Json snippet '<--error-->�{name:')
What am I doing wrong?
EDIT:
I have done it with a PowerShell Script now, and it does work.
So, what my problem is: I am placing my own recorded episodes in this folder where I want sonarr to import it from.
Could some one tell me how write a loop that sends this command to sonarr for each subdirectroy wich will contain the episode in this “C:\some_path” directory?
This is the basic script I have copied from the forum.
$url = "http://localhost:8989/api/command"
$json = "{ ""name"": ""DownloadedEpisodesScan"", ""path"": ""C:\\some_path"" }"
Write-Host "Publishing update $version ($branch) to: $url"
Invoke-RestMethod -Uri $url -Method Post -Body $json -Headers @{"X-Api-Key"="xxxx"}
EDIT#2:
Alright, this could have been a chance for me to learn something about powershell scripts, recursion, loops, etc.,… But I found a script to copy…
On reddit theres a script that pretty much does what drone factory did:
Credits go to CyrixMXi-233
Source: https://www.reddit.com/r/sonarr/comments/6zl22j/drone_factory_alternative_script/
Script:
$allitems=@(Get-ChildItem -Recurse \\YourSMBShareHere\media\complete | ?{ $_.PSIsContainer }).fullname #get list of all folders in your completed downlaods directory.
for($i=0;$i -lt $allitems.count;$i++){ #iterate through folders
$escaped = $allitems.get($i).replace('\','\\') #add necessary escape characters
$url = "http://YOURIPHERE:8989/api/command" #change to your Sonarr URL.
$json1 = "{ ""name"": ""downloadedepisodesscan"",""path"": """ #beginning of body
$json2 = """}" #end of body
$jsoncomplete = $json1 + $escaped + $json2 #piece body together.
Invoke-RestMethod -Uri $url -Method Post -Body $jsoncomplete -Headers @{"X-Api-Key"="YOURAPIKEYHERE"} #do it
}
Hope it’s fine that I share this.
And I hope this helps others finding this script.