AMC Specify plex library ID's for content based updates

All your suggestions, requests and ideas for future development
Post Reply
User avatar
mrbucket101
Power User
Posts: 36
Joined: 02 Jul 2014, 00:25

AMC Specify plex library ID's for content based updates

Post by mrbucket101 »

I'm not sure if the filebot documentation has been updated, but there is now a new way to generate permanent API tokens. I used the powershell method supplied in this post. I added echo $token to the end to view my resultant key.

I know AMC has native support for updating the plex library automatically, but unfortunately, that only uses HTTP (not HTTPS - so I have to configure plex to Prefer secure connections, instead of require them). On top of this, filebot is requesting an update of ALL libraries, instead of a specific library. With my collection that can take upwards of 5-7 minutes to finish scanning. I was hoping that we could update AMC to provide additional arguments for the respective plex libraries. Filebot already knows if something is a Movie/TV/Anime, so it shouldn't be too hard to only update that specific library.

I have manged to implement this functionality myself in my bash script, but I was hoping to have it become native as that is superior to my grep checks.

Code: Select all

#!/bin/bash
FILE_PATH=$1
        filebot -script fn:amc \
        -no-xattr \
        --output "/home/user/Share" \
        --log-file amc.log \
        --action copy \
        --conflict auto \
        -non-strict \
        "$FILE_PATH" \
        --filter "!readLines('''/home/user/.filebot/filter.txt''').contains(n)" \
        --def @/home/user/.filebot/args.txt
	&& 
	if echo $FILE_PATH | grep -Eq 'Downloads/Movies|Share/Movies'; then
		exec curl --insecure https://<plex_host>:<plex_port>/library/sections/1/refresh?X-Plex-Token=<plex-api-token>
	elif echo $FILE_PATH | grep -Eq 'Downloads/TV|Share/TV'; then
		exec curl --insecure https://<plex_host>:<plex_port>/library/sections/2/refresh?X-Plex-Token=<plex-api-token>
	elif echo $FILE_PATH | grep -Eq 'Downloads/Anime|Share/Anime'; then
		exec curl --insecure https://<plex_host>:<plex_port>/library/sections/12/refresh?X-Plex-Token=<plex-api-token>
	fi
For my personal setup, Movies is library ID 1, TV is library ID 2, and Anime is library ID 12

Here is my args.txt file

Code: Select all

music=n
clean=y
artwork=n
extras=n
unsorted=n
pushover=<key>:<token>
subtitles=en
musicFormat=Music/{n}/{album+'/'}{pi.pad(2)+' - '}{artist} - {t}
seriesFormat=TV/{plex.tail}
movieFormat={plex}
Also, I'm a patreon subscriber, as well as an owner of the windows store app. (Gotta support the dev as much as I can) - Is there a way to hide the patreon message? It's cluttering my log files. Not a huge deal, but would be nice to hide.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: AMC Specify plex library ID's for content based updates

Post by rednoah »

1.
The amc script uses HTTPS by default, unless you pass in an IP as plex host, then it'll use HTTP because HTTPS doesn't work with IP addresses (unless you disable some security aspects).


2.
I recommend using --def exec to generate the appropriate curl calls.

e.g. yield 1/2/12 depending on the object type:

Code: Select all

any{anime ? 12 : 2}{1}
e.g. use generate curl calls accordingly:

Code: Select all

--def exec="curl --insecure https://<plex_host>:<plex_port>/library/sections/{any{anime ? 12 : 2}{1}}/refresh?X-Plex-Token=<plex-api-token>"
:idea: Please read the FAQ and How to Request Help.
User avatar
mrbucket101
Power User
Posts: 36
Joined: 02 Jul 2014, 00:25

Re: AMC Specify plex library ID's for content based updates

Post by mrbucket101 »

rednoah wrote: 25 Apr 2018, 05:01 1.
The amc script uses HTTPS by default, unless you pass in an IP as plex host, then it'll use HTTP because HTTPS doesn't work with IP addresses (unless you disable some security aspects).


2.
I recommend using --def exec to generate the appropriate curl calls.

e.g. yield 1/2/12 depending on the object type:

Code: Select all

any{anime ? 12 : 2}{1}
e.g. use generate curl calls accordingly:

Code: Select all

--def exec="curl --insecure https://<plex_host>:<plex_port>/library/sections/{any{anime ? 12 : 2}{1}}/refresh?X-Plex-Token=<plex-api-token>"
Thanks! That seems to be working perfectly.

Code: Select all

any{anime ? 12 : 2}{1}
Could you perhaps explain a bit more how the boolean logic works though. I'm curious to understand more. I see the ternary operators and that makes sense. The any operator, and the third condition are confusing me a little bit.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: AMC Specify plex library ID's for content based updates

Post by rednoah »

The {anime} binding returns true for AniDB episode objects and false for TheTVDB episodes. It will fail (i.e. throw an exception) for Movie objects.

You can also use if-then-else and ternary operators using the {type} and {info.database} bindings.
:idea: Please read the FAQ and How to Request Help.
Post Reply