filebot and sonarr import again

Any questions? Need some help?
ZeroByDivide
Posts: 170
Joined: 16 Dec 2014, 01:39

Re: filebot and sonarr import again

Post by ZeroByDivide »

terxw wrote: 21 Mar 2019, 20:49
ZeroByDivide wrote: 19 Mar 2019, 03:57

Are you just calling my script and not doing a full filebot command with the AMC script and such? I'd need to see your full filebot command, along with a full log otherwise I can't really see exactly what it is that you are doing wrong as right now it just looks like you are just calling my script alone which I don't think will work exactly (never tried though so I can't say for sure if it would or not be able to be standalone), you would need to append the

Code: Select all

--def "exec=filebot -script /path/to/Update_Sonarr_Radarr.groovy --def type={type} id={id}"
to the end of a normal filebot command that is using things like the amc script.

Example:

Code: Select all

filebot -script fn:amc --output "X:/Media" --action duplicate --conflict skip -non-strict --log-file amc.log --def unsorted=y music=y artwork=y "ut_label=%L" "ut_state=%S" "ut_title=%N" "ut_kind=%K" "ut_file=%F" "ut_dir=%D" --def "exec=filebot -script /path/to/Update_Sonarr_Radarr.groovy --def type={type} id={id}"
Also make sure that you are going in the Update_Sonarr_Radarr.groovy script, and replacing the "PLACEAPIKEYHERE" bits with your the APIs for your sonarr / radarr, and if you are running behind a url base you need to edit lines 13 and 20 for sonarr / 35 and 42 for radarr.

I'm going to eventually set up a readme on my repository, but I just haven't had the time to really do it as I've been pretty busy IRL and when I do have time I'm usually busy working on something else.
Thank you for your time!

Yes I am calling the exec after full filebot with amc script command, action, hardlink, movie identification are alright, just the exec part fails

I am running transmission and filebot in docker .

Code: Select all

SCRIPT_DIR="/data/transmission-home/"
CONFIG_OUTPUT="/data/storage/Movies/_sorted"

ACTION="HARDLINK"                                                                                                                                                                                                                         
                                                                                                                                                                                                                                           
LAN="EN"                                                                                                                                                                                                                                  
#                                                                                                                                                                                                                                         
LANS="EN" 
export DISPLAY="";                                                                                                                                                                                                                        
/usr/bin/filebot  -script fn:amc --output  "$CONFIG_OUTPUT" -non-strict --conflict SKIP --db TheMovieDB --lang sk --action "$ACTION" --encoding UTF-8 --log all --log-file "$LOG"  --def "excludeList=amc7.txt" --def "subtitles=en,cs,sk" "artwork=n" "clean=y" "unsorted=n" "extras=y" "storeReport=y" --def "movieFormat=Movies/{localize.cs.n} - {primaryTitle} ({y}) {vf} {vc} {ac} {any{media.AudioLanguageList.ISO3.upper()}{fn.matchAll(/(CZ|cz|cse|CZECH|Czech)/) ? ' CZ' : '' }{fn.matchAll(/(SK|SVK|svk|Slovak|Sk)/) ? ' SK' : '' }}/{primaryTitle} ({y}) {vf} {vc} {ac} {any{media.AudioLanguageList.ISO3.upper()}{fn.matchAll(/(CZ|cz|cse|CZECH|Czech)/) ? ' CZ' : '' }{fn.matchAll(/(SK|SVK|svl|Slovak|Sk)/) ? ' SK' : '' }} ({fn.replaceAll(/[:]+$/, ' - ').upperInitial()})" --def "seriesFormat=TV/{localize.cs.n} ({primaryTitle}) {any{media.AudioLanguageList.ISO3.upper()}{fn.matchAll(/(CZ|cz|cse|CZECH|Czech)/) ? ' CZ' : '' }{fn.matchAll(/(SK|SVK|svk|Slovak|Sk)/) ? ' SK' : '' }{'$LANS'}}/{episode.special ? {localize.cs.n}+' - Specials' : {localize.cs.n}+' - Season '+s.pad(2)}/{localize.cs.n} - {episode.special ? 'S00E'+special.pad(2) : s00e00} - {t} {any{media.AudioLanguageList.ISO3.upper()}{fn.matchAll(/(CZ|cz|cse|CZECH|Czech)/) ? ' CZ' : '' }{fn.matchAll(/(SK|SVK|svk|Slovak|Sk)/) ? ' SK' : '' }{'$LANS'}}{'.'+lang}" --def "ut_dir=$ARG_PATH" "ut_kind=multi" --def "exec=filebot -script $SCRIPT_DIR/Update_Sonarr_Radarr.groovy --def type={type} id={id}"



Filebot log

Code: Select all

Run script [fn:amc] at [Thu Mar 21 19:15:32 UTC 2019]
Parameter: excludeList = amc.txt
Parameter: subtitles = en,cs,sk
Parameter: artwork = n
Parameter: clean = y
Parameter: unsorted = n
Parameter: extras = y
Parameter: storeReport = y
Parameter: movieFormat = Movies/{localize.cs.n} - {primaryTitle} ({y}) {vf} {vc} {ac} {any{media.AudioLanguageList.ISO3.upper()}{fn.matchAll(/(CZ|cz|cse|CZECH|Czech)/) ? ' CZ' : '' }{fn.matchAll(/(SK|SVK|svk|Slovak|Sk)/) ? ' SK' : '' }}/{primaryTitle} ({y}) {vf} {vc} {ac} {any{media.AudioLanguageList.ISO3.upper()}{fn.matchAll(/(CZ|cz|cse|CZECH|Czech)/) ? ' CZ' : '' }{fn.matchAll(/(SK|SVK|svl|Slovak|Sk)/) ? ' SK' : '' }} ({fn.replaceAll(/[:]+$/, ' - ').upperInitial()})
Parameter: seriesFormat = TV/{localize.cs.n} ({primaryTitle}) {any{media.AudioLanguageList.ISO3.upper()}{fn.matchAll(/(CZ|cz|cse|CZECH|Czech)/) ? ' CZ' : '' }{fn.matchAll(/(SK|SVK|svk|Slovak|Sk)/) ? ' SK' : '' }{'EN'}}/{episode.special ? {localize.cs.n}+' - Specials' : {localize.cs.n}+' - Season '+s.pad(2)}/{localize.cs.n} - {episode.special ? 'S00E'+special.pad(2) : s00e00} - {t} {any{media.AudioLanguageList.ISO3.upper()}{fn.matchAll(/(CZ|cz|cse|CZECH|Czech)/) ? ' CZ' : '' }{fn.matchAll(/(SK|SVK|svk|Slovak|Sk)/) ? ' SK' : '' }{'EN'}}{'.'+lang}
Parameter: ut_dir = /data/storage/pve/Downloads/completed/McQueen.2018.BDrip.AAC.1080p.x264-VINEnc.mp4
Parameter: ut_kind = multi
Parameter: ut_title = McQueen.2018.BDrip.AAC.1080p.x264-VINEnc.mp4
Parameter: ut_label = N/A
Parameter: exec = filebot -script /data/transmission-home/Update_Sonarr_Radarr.groovy --def type={type} id={id}
Use excludes: /data/storage/Movies/_sorted/amc7.txt (2)
Input: /data/storage/pve/Downloads/completed/McQueen.2018.BDrip.AAC.1080p.x264-VINEnc.mp4
xattr: [McQueen.2018.BDrip.AAC.1080p.x264-VINEnc.mp4] => [McQueen (2018)]
Group: [mov:mcqueen 2018] => [McQueen.2018.BDrip.AAC.1080p.x264-VINEnc.mp4]
Get [English] subtitles for 1 files
Looking up subtitles by hash via OpenSubtitles
No matching subtitles found: /data/storage/pve/Downloads/completed/McQueen.2018.BDrip.AAC.1080p.x264-VINEnc.mp4
Get [Czech] subtitles for 1 files
Looking up subtitles by hash via OpenSubtitles
No matching subtitles found: /data/storage/pve/Downloads/completed/McQueen.2018.BDrip.AAC.1080p.x264-VINEnc.mp4
Get [Slovak] subtitles for 1 files
Looking up subtitles by hash via OpenSubtitles
No matching subtitles found: /data/storage/pve/Downloads/completed/McQueen.2018.BDrip.AAC.1080p.x264-VINEnc.mp4
Rename movies using [TheMovieDB]
Auto-detect movie from context: [/data/storage/pve/Downloads/completed/McQueen.2018.BDrip.AAC.1080p.x264-VINEnc.mp4]
[HARDLINK] from [/data/storage/pve/Downloads/completed/McQueen.2018.BDrip.AAC.1080p.x264-VINEnc.mp4] to [/data/storage/Movies/_sorted/Movies/McQueen - McQueen (2018) 1080p x264 AAC/McQueen (2018) 1080p x264 AAC (McQueen.2018.BDrip.AAC.1080p.X264-VI
NEnc).mp4]
Processed 1 files
Execute: filebot -script /data/transmission-home/Update_Sonarr_Radarr.groovy --def type=Movie id=508003

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedConstructor$1 (file:/usr/share/filebot/jar/groovy.jar) to constructor java.nio.HeapByteBuffer(byte[],int,int,int,int,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedConstructor$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Cannot get property 'id' on null object
java.lang.NullPointerException: Cannot get property 'id' on null object
        at Script1.run(Script1.groovy:35)
        at net.filebot.cli.ScriptShell.evaluate(ScriptShell.java:64)
        at net.filebot.cli.ScriptShell.runScript(ScriptShell.java:74)
        at net.filebot.cli.ArgumentProcessor.runScript(ArgumentProcessor.java:154)
        at net.filebot.cli.ArgumentProcessor.run(ArgumentProcessor.java:36)
        at net.filebot.Main.main(Main.java:131)

Failure (°_°)
Saving report as /home/kangus/.filebot/reports/2019-03-21_21_37_McQueen_2018_BDrip_AAC_1080p_x264-VINEnc.html
Done ヾ(@⌒ー⌒@)ノ
Here is my Update_Sonarr_Radarr.groovy script

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://IPADDRES:9015')                                                                                                                                                                                          
    def header = ['X-Api-Key': '11111111111111111111']                                                                                                                                                                         
                                                                                                                                                                                                                                           
    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://IPADDRESS:9014')                                                                                                                                                                                          
    def header = ['X-Api-Key': '111111111111111111111111']                                                                                                                                                                         
                                                                                                                                                                                                                                           
    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                                                                                                                                                                                                                                 
} 
Hmm this is really strange because I've had no issues here myself, nor has the few other people I know who use the script. I even redownloaded radarr (since I seen that was what you was running against in the log above and I don't personally use radarr yet) to run some tests and didn't have any issues whats so ever, but everyone I know who is at least running the script and myself don't use docker so that could be a possible lead there but I'm honestly not sure as it wouldn't really make much sense :L does it work for the sonarr side of things or is it throwing an error when you do shows as well? does it throw any type of errors in sonarr(if sonarr is doing it as well)/radarr logs?

if possible could you run

Code: Select all

curl -s http://IPADDRESS:9014/api/movie -H "X-Api-Key: apikey" --compressed
replace the url bit and the "apikey" with whatever you need to, and throw up what it says? Since I sadly can't reproduce the issue, and I can't run docker to be able to test if there are any issues with running the script against sonarr/radarr in docker, @rednoah may need to step in here to help any further.
Post Reply