use --filter to match the id

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
Reneg
Posts: 37
Joined: 04 Jan 2012, 20:32

use --filter to match the id

Post by Reneg »

Dears,


here is my test string:

Code: Select all

filebot -script 'dev:amc' /source --output /RASPI-STORAGE-PLEX --action TEST --order Airdate --conflict auto --filter 'any{f.folder.name.indexOf(id) > 0}' --lang en --def 'clean=y' 'skipExtract=y' 'minFileAge=0.125' 'seriesFormat=/RASPI-STORAGE-PLEX/italian/{ if(anime){return "ANIME SERIES"}else if(genres.contains("Animation")){return "CARTONI"}else{"TVS"} }\{plex.tail}{if (dc > 1) '\''.'\''+di}' 'movieFormat=/REMOTE-WIKIBOX-1/italian/{height <= 1080 ? genre != "Animation" ? "MOVIES": "ANIMATION" : genre != "Animation" ? "MOVIES 4K" : "ANIMATION 4K"}\{plex.tail}' 'seriesDB=TheTVDB' 'unsortedFormat=/STORAGE/toSort/{relativeFile}' 'excludeList=/storage/logs/.excludes' --apply refresh --log all --log-file '/data/node/filebot.log'
all the source file are named with the ID in the path follow:

Code: Select all

/source/SERIES/Pretty Little Liars Original Sin - Stagione 2 (2022) - 1080P-HEVC - ID-389085/Pretty Little Liars - Original Sin S02E05 Venerdì 13 1080.mkv
as filter:

Code: Select all

--filter 'any{f.indexOf(id) > 0}'
partial log:

Code: Select all

Apply filter [any{f.indexOf(id) > 0}] on [225] options
Exclude [Pretty Little Liars (2022) - 1x01 - Chapter One: Spirit Week]
Exclude [Pretty Little Liars (2022) - 1x02 - Chapter Two: The Spirit Queen]
Exclude [Pretty Little Liars (2022) - 1x03 - Chapter Three: Aftermath]
Exclude [Pretty Little Liars (2022) - 1x04 - Chapter Four: The (Fe)male Gaze]
Is there any smart way to match the id with the folder string variable and if there is a match to grant the match ?
User avatar
rednoah
The Source
Posts: 23237
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: use --filter to match the id

Post by rednoah »

:idea: --filter expressions only have Movie / Episode bindings available at the time. File bindings such as f will be unavailable and fail as no file has been matched.



:idea: If you wanted to allow only specific IDs for matching, then you could maintain a list of allowed IDs:

Shell: Select all

--filter 'id in lines("/path/to/includes.tsv")'
This list of allowed IDs could be generated from the file paths you have as needed like so:

Console Output: Select all

$ find /source | egrep  -o 'ID-[0-9]+' | cut -c 4- | sort -u | tee "/path/to/includes.tsv"
389085



:idea: That said, in this particular case, the --filter option is the wrong tool for the job at hand. You'll want to use the --q option to force the known ID for each file at hand:
rednoah wrote: 20 Aug 2020, 11:26 e.g. Match ID12345 pattern from the filename and then use it as query:

Shell: Select all

--q "{ fn.match(/ID([0-9]{5,11})/) }"


:arrow: In this particular case, you would match 389085 from the file path and then force that for lookup like so:

Shell: Select all

--q "{ f.path.match(/ID-([0-9]+)/) }"
:idea: Please read the FAQ and How to Request Help.
Post Reply