Plex refresh wrong target path is chosen

Support for Ubuntu and other Desktop Linux distributions
Post Reply
Technosoft2000
Posts: 5
Joined: 12 Jun 2022, 17:02

Plex refresh wrong target path is chosen

Post by Technosoft2000 »

Hi,

I've in Plex a Movie library defined with two target folders:
- /streaming/Amazon (buy)/Filme
- /movies

Here a screenshot for better understanding what I mean:

Image

Both are successfully scanned by Plex and shown under the target menu entry Movie (Filme).

Image

I use Filebot via the latest Docker version:

Code: Select all

docker run --rm -it -v filebot-data:/data rednoah/filebot -version
FileBot 4.9.6 (r9125)
Nevertheless, it doesn't matter which source path is defined via Filebot command line the Plex refresh logic uses always the first defined entry of the Movie library, which is in the above mentioned case /streaming/Amazon (buy)/Filme and this is not always the correct one. In some cases the second entry /movies must be used. Due the wrong chosen entry my Plex doesn't refresh correctly and the new movie isn't shown there.

I've detected the issue via the filebot.log:

Code: Select all

Processed 1 file
Notify Plex [192.168.0.100]
GET: http://192.168.0.100:32400/library/sections/3/refresh?path=%2Fstreaming%2FAmazon+%28buy%29%2FFilme%2FAnimation%2FThe+Ice+Age+Adventures+of+Buck+Wild+%282022%29&X-Plex-Token=XXXXXXXXXXXXXXX
Is there some possibility to define which target entry should be used? Have I overseen any existing parameter yet?

Here my call:

Code: Select all

docker run --rm -t \
-v /volume1/downloads:/volume1/downloads \
-v /volume1/video:/volume1/video \
-v /volume1/extensions/scripts/filebot:/volume1/extensions/scripts/filebot \
-v filebot-data:/data \
--entrypoint /usr/bin/filebot \
rednoah/filebot \
    -rename \
    -script 'fn:amc' /volume1/downloads/complete/movie \
    --output /volume1/video/Filme \
    --action move \
    -non-strict \
    --conflict auto \
    --lang de \
    --def 'ut_label=movie' \
    --def 'clean=y' \
    --def 'skipExtract=y' \
    --def 'ignore=.*_UNPACK_.*$' \
    --def 'pushover=XXXXXXXXXXXXXXXXXXXXXX' \
    --def 'movieFormat={genre}/{n} ({y}) [{any{source.match('\''BD'\'').replace('\''BD'\'','\''BDRip'\'')}{source.match('\''BluRay'\'').replace('\''BluRay'\'','\''BDRip'\'')}{source.match('\''DVD'\'').replace('\''DVD'\'','\''DVDRip'\'')}{source}{sdhd == '\''HD'\'' ? '\''BDRip'\'' : '\''DVDRip'\''}}, {vc}, {vf}, {ac}, {af.replace('\''6ch'\'','\'' 5.1'\'').replace('\''8ch'\'','\'' 7.2'\'').replace('\''3'\'', '\'' 2.1'\'').replace('\''2ch'\'','\'' 2.0'\'').replace('\''1ch'\'','\'' 1.0'\'').replace('\''7ch'\'','\'' 6.1'\'').replace('\''3ch'\'','\'' 2.1'\'')}]/{ny}{'\'' CD'\''+pi}{subt}' \
    --def 'music=n' \
    --def 'artwork=n' \
    --def 'excludeList=.excludes' \
    --def 'exts=jpg|png|nfo|srv|srr|nzb|sfv|idx|sub|txt|part01|part02|par1|par2' \
    --def 'terms=sample|trailer|etc' \
    --def 'plex=192.168.0.200:XXXXXXXXXXXXXXXXXX' \
    --log all \
    --log-file /volume1/extensions/scripts/filebot/filebot.log
Thanks for your help and support :)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Plex refresh wrong target path is chosen

Post by rednoah »

--def plex only works for typical configurations, but you can always use curl kick off a refresh.


e.g.

Code: Select all

curl -v "http://<IP>:32400/library/sections/all/refresh?X-Plex-Token=<TOKEN>"





:!: Note that this will prevent you from using move, hardlink and clone operations:

Code: Select all

-v /volume1/downloads:/volume1/downloads \
-v /volume1/video:/volume1/video \
You'll want input and output folder on the same file system, from the container point-of-view:
https://github.com/filebot/filebot-dock ... n-hardlink


:!: Note that these lines have no effect:

Code: Select all

    --def 'exts=jpg|png|nfo|srv|srr|nzb|sfv|idx|sub|txt|part01|part02|par1|par2' \

Code: Select all

    --def 'terms=sample|trailer|etc' \
--def exts and --def terms are script parameters for the cleaner script. The amc script doesn't use them.




EDIT:


:!: You're moving files to a folder called "Filme" and so FileBot will refresh the Plex Media Root Folder that is named "Filme" and that happens to be the first one on the list:

Code: Select all

-script 'fn:amc' /volume1/downloads/complete/movie \
    --output /volume1/video/Filme \
Your output folder should be named "movies" if you want to refresh a folder named "movies". FileBot generally doesn't know the local file structure of your remote Plex host, file system redirection via docker, etc. FileBot can only guess which local destination path responds to which remote Plex host path by comparing folder names and then sending a refresh request to every possible option:
https://github.com/filebot/scripts/blob ... groovy#L39


tl;dr you're moving files to a folder named "Filme" and so FileBot will only refresh the folder named "Filme" and not the folder named "movies".
:idea: Please read the FAQ and How to Request Help.
Technosoft2000
Posts: 5
Joined: 12 Jun 2022, 17:02

Re: Plex refresh wrong target path is chosen

Post by Technosoft2000 »

Thanks for all this hints :)

I'll incorporate all your remarks regarding my current filebot call and give feedback as soon as possible.
Technosoft2000
Posts: 5
Joined: 12 Jun 2022, 17:02

Re: Plex refresh wrong target path is chosen

Post by Technosoft2000 »

By the way, the different paths can be confusing since they are two different Docker containers and the paths are mounted differently there for historical reasons. Nevertheless the renaming part and moving part works without any issues at all.

The reason why I've included the variables for the cleaning part was because I've seen it somewhere in the forum, and I thought that the cleaning script part is executed automatically with the amc script, but it's no problem to execute it by myself afterwards.

I'll check https://github.com/filebot/scripts/blob ... groovy#L39 - thanks for the detailed information.
Technosoft2000
Posts: 5
Joined: 12 Jun 2022, 17:02

Re: Plex refresh wrong target path is chosen

Post by Technosoft2000 »

Regarding https://github.com/filebot/scripts/blob ... groovy#L39 I see that the script access the URL http://<IP>:32400/library/sections/?X-Plex-Token=<TOKEN> and this delivers for my configuration:

Code: Select all

<MediaContainer size="5" allowSync="0" title1="Plex Library">
<Directory allowSync="1" art="/:/resources/movie-fanart.jpg" composite="/library/sections/3/composite/1655307304" filters="1" refreshing="0" thumb="/:/resources/movie.png" key="3" type="movie" title="Filme" agent="tv.plex.agents.movie" scanner="Plex Movie" language="de-DE" uuid="9a453e27-580f-4319-81f6-e20a5d66b6ff" updatedAt="1655307359" createdAt="1587852497" scannedAt="1655307304" content="1" directory="1" contentChangedAt="3725796" hidden="0">
<Location id="10" path="/streaming/Amazon (buy)/Filme"/>
<Location id="3" path="/movies"/>
</Directory>
...
The amc script has the follwing extraction code:

Code: Select all

		xml.'Directory'.'Location'.collect{ location ->
			def key = location.'..'.'@key'.text()
			def path = location.'@path'.text()
			def root = path.split(/[\\\/]/).last()
			libraryRoot[root] += [key: key, path: path]
		}
but the XML doesn't have an attribute 'key' - I think instead of 'key' the attribute 'id' should be used.

Nevertheless it would be great when both locations (or all defined locations) are getting refreshed or it would be at least great to have the possibility to specify which target location should be refreshed :D

For the moment I use your suggested approach with cURL ;)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Plex refresh wrong target path is chosen

Post by rednoah »

:idea: '..'.'@key' selects key="3" which then allows it to refresh sections/3


:idea: The current behaviour works efficiently (refresh all is not desirable) out-of-the-box for almost all use cases. A fallback for refreshing everything if no <Location> matches (i.e. don't use --output /path/to/Filme if you don't want it to accidentally match /path/to/Filme) also already exists. A special case for misleading use cases (i.e. /volume1/video/Filme corresponds to /movies and not /some/path/to/Filme) is not planned, unless this turns out to be a common problem.


:arrow: tl;dr use --output /path/to/movies inside the filebot container and update the volume mount configuration accordingly; then filebot inside the filebot container will see a output folder named movies, and instruct Plex inside the plex container to rescan library folder named movies.

:arrow: Alternatively, change the Plex container volume mount configuration so that your /movies folder is available under /path/to/Filme instead.

:arrow: Alternatively, change the Plex container volume mount configuration so that your /streaming/Amazon (buy)/Filme folder is available under /streaming-movies instead.
:idea: Please read the FAQ and How to Request Help.
Technosoft2000
Posts: 5
Joined: 12 Jun 2022, 17:02

Re: Plex refresh wrong target path is chosen

Post by Technosoft2000 »

ohh I've overseen that '..' is used to go up to the element Directory :roll: thanks for the clarification.

Okay I'll test you suggestions, thanks for your support :)
Post Reply