How to Force FileBot to update Sonarr/Radarr

Support for Ubuntu and other Desktop Linux distributions
Post Reply
eikum
Posts: 4
Joined: 23 Apr 2017, 11:40

How to Force FileBot to update Sonarr/Radarr

Post by eikum »

Hi all,

First of all, thanks for the help! :)

Okey, I got a problem here guys. Let me try to explain this.
I run Sonarr/Radarr local server, then an external server for FileBot and Sabnzbd.

Sonarr/Radarr push the file to Sabnzbd, and then I use fn:amc to rename and move the file where I want it.
So far, so good. (I wish that AMC got Sonarr/Radarr support.. :roll: )

But here is the issue. Sonarr/Radarr only updated all series every 30 mins or something. So, how can I get filebot to notify Sonarr/Radarr to only update the "item" that FileBot just finished?

For the past 3 days I have tried to figure out how to do this, but I'm stuck :(

PS! Im not a "scripter", but sometimes I understand how things are linked together.. Sometimes :oops:

//I have a "quick fix". This command will refresh all Series, but, I don't like it.
//"curl http://192.168.1.100:9000/api/command -X POST -d '{"name": "RefreshSeries"}' --header "X-Api-Key:APIKEY""

Probably someone here can help me :)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to Force FileBot to update Sonarr/Radarr

Post by rednoah »

You can use --def exec to hook your curl call into the amc script.


:idea: Solutions that are simple and independently testable are beautiful. ;)
:idea: Please read the FAQ and How to Request Help.
eikum
Posts: 4
Joined: 23 Apr 2017, 11:40

Re: How to Force FileBot to update Sonarr/Radarr

Post by eikum »

ahh! Thats new to me! Then I starting to see how I should do it.

So, this should work?

Code: Select all

filebot -script fn:amc --log-file amc.log --action copy -non-strict --conflict skip -non-strict "$HOME/test/LAlala/" 
--def "seriesFormat=$HOME/media/'TV Shows'/{n}/{'Season '+s.pad(2)}/{n} - {S00E00} - {t}" 
--def "movieFormat=$HOME/media/Movies/{n} [{y}]" 
--def clean=y 
--def exec="curl http://192.168.1.100:9000/api/command -X POST -d '{"name": "RefreshSeries"}' --header "X-Api-Key:APIKEY""
But, how can I force the curl to only update this specific movie or show?

I found something on the Sonarr.tv forum, but don't understand how I can make this script to work with FileBot.

Code: Select all

#!/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'" }'
Thanks for your help, I really appreciate it
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: How to Force FileBot to update Sonarr/Radarr

Post by devster »

I believe you can use the second script you mentioned as exec argument and use variables to pass the series name.
Something like

Code: Select all

--def exec="/path/to/myscript.sh {n}"
and in the second script add a line like

Code: Select all

seriesName=${1}
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to Force FileBot to update Sonarr/Radarr

Post by rednoah »

I'd also recommend writing your own update-sonarr.sh script to make the --def exec command as simple as possible, and the update-sonarr.sh script independently testable:


e.g.

Code: Select all

--def exec="/path/to/update-sonarr.sh {quote n}"

:idea: Nested "..." don't work the way you think, i.e. you can't nest them without escaping them. Please read Cmdline and Argument Passing for details.
:idea: Please read the FAQ and How to Request Help.
AbedlaPaille
Posts: 107
Joined: 12 Apr 2020, 04:02

Re: How to Force FileBot to update Sonarr/Radarr

Post by AbedlaPaille »

eikum wrote: 02 Apr 2020, 20:04 ahh! Thats new to me! Then I starting to see how I should do it.

So, this should work?

Code: Select all

filebot -script fn:amc --log-file amc.log --action copy -non-strict --conflict skip -non-strict "$HOME/test/LAlala/" 
--def "seriesFormat=$HOME/media/'TV Shows'/{n}/{'Season '+s.pad(2)}/{n} - {S00E00} - {t}" 
--def "movieFormat=$HOME/media/Movies/{n} [{y}]" 
--def clean=y 
--def exec="curl http://192.168.1.100:9000/api/command -X POST -d '{"name": "RefreshSeries"}' --header "X-Api-Key:APIKEY""
But, how can I force the curl to only update this specific movie or show?

I found something on the Sonarr.tv forum, but don't understand how I can make this script to work with FileBot.

Code: Select all

#!/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'" }'
Thanks for your help, I really appreciate it
Did you ever found how to do this? Trying to do the exact same thing.
Rembold04
Posts: 9
Joined: 06 Dec 2019, 21:28

Re: How to Force FileBot to update Sonarr/Radarr

Post by Rembold04 »

Late to the game here, but I use this script:

https://github.com/JourneyDeprecated/fi ... arr.groovy

Code: Select all

// TVDB/TMDB ID
def id = id as int

// Video Type
def type = type

// Sonarr API Configuration
if (type =~ /Episode/) {
    def url = new URL('http://localhost:8989')
    def header = ['X-Api-Key': 'PLACEAPIKEYHERE']

    def sonarrSeriesId = new JsonSlurper()
        .parseText(new URL(url, '/api/series')
            .get(header)
            .text)
        .find {
            it.tvdbId == id
        }.id

    println new URL(url, '/api/command').post(
        JsonOutput.toJson(
            [name: 'rescanSeries', seriesId: sonarrSeriesId]
        ).getBytes('UTF-8'),
        'application/json',
        header
    ).text
}

// Radarr API Configuration
if (type =~ /Movie/) {
    def url = new URL('http://localhost:7878')
    def header = ['X-Api-Key': 'PLACEAPIKEYHERE']

    def radarrMovieId = new JsonSlurper()
        .parseText(new URL(url, '/api/movie')
            .get(header)
            .text)
        .find {
            it.tmdbId == id
        }.id

    println new URL(url, '/api/command').post(
        JsonOutput.toJson(
            [name: 'rescanMovie', movieId: radarrMovieId]
        ).getBytes('UTF-8'),
        'application/json',
        header
    ).text
}
Just save the script as a file somewhere that Filebot has access to. Update the URLs and API keys for both Sonarr and Radarr.

Then add this to the end of your AMC script replacing the directory/filename as needed:

Code: Select all

--def exec="/data/scripts/Update_Sonarr_Radarr.groovy --def type={type} id={id}"
You may or may not need escape characters ("\" or "\\") in front of the "=" depending on how you are calling Filebot and what OS you are using.

My call actually looks like this since it is within the Docker run command:

Code: Select all

-exec filebot -script /data/scripts/Update_Sonarr_Radarr.groovy --def type\\={type} id\\={id}
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to Force FileBot to update Sonarr/Radarr

Post by rednoah »

Note that making your *.groovy script executable only works if you also add the correct shebang in the first line so that the system can run the script with the appropriate executable:

Code: Select all

/data/scripts/Update_Sonarr_Radarr.groovy
1st line:

Code: Select all

#!/usr/bin/env filebot -script
https://github.com/filebot/scripts/blob ... nfo.groovy
:idea: Please read the FAQ and How to Request Help.
Post Reply