Page 1 of 1

Using filter to exclude and handle ambiguous file

Posted: 15 Nov 2024, 08:11
by b0ssem
Hi,

Im trying to wrap my head around using --q / --filter to match a tv show. It seems like there is something Im missing here.

As you can see, the script has issues finding the right show when not using any filters

Code: Select all

Run script [fn:amc] at [Fri Nov 15 08:17:41 CET 2024]
Parameter: movieFormat = O:/{vf =~ /2160p|4K/ ? '4K' : genres =~ /Family|Children|Animation/ ? 'Barnfilm' : 'X264-10'}/{n.upperInitial()} ({y})/{n.upperInitial()} ({y})
Parameter: seriesFormat = O:/{genres =~ /Children/ ? 'Barn-TV' : 'TV-12'}/{n.upperInitial()}/S{s.pad(2)}/{n.upperInitial()} - {s00e00} - {t}
Parameter: seriesDB = TheTVDB
Parameter: movieDB = TheMovieDB
Parameter: skipExtract = y
Parameter: excludeList = C:\TV-IN\Filebot\amc.txt
Parameter: subtitles = swe,eng
Parameter: unsorted = y
Parameter: clean = y
Parameter: plex = *****
Argument[0]: C:\TV-IN\TV
Use excludes: C:\TV-IN\Filebot\amc.txt (0)
Input: C:\TV-IN\TV\Bachelor.Sverige.S08E31.SWEDiSH.1080p.WEB.h264-OLLONBORRE\bachelor.sverige.s08e31.swedish.1080p.web.h264-ollonborre.mkv
Group files by movie or series
Group: {Series=The Bachelor (2002)} => [bachelor.sverige.s08e31.swedish.1080p.web.h264-ollonborre.mkv]
Get [Swedish] subtitles for 1 file
Looking up subtitles by hash via OpenSubtitles
No subtitles: C:\TV-IN\TV\Bachelor.Sverige.S08E31.SWEDiSH.1080p.WEB.h264-OLLONBORRE\bachelor.sverige.s08e31.swedish.1080p.web.h264-ollonborre.mkv (Swedish)
Get [English] subtitles for 1 file
Looking up subtitles by hash via OpenSubtitles
No subtitles: C:\TV-IN\TV\Bachelor.Sverige.S08E31.SWEDiSH.1080p.WEB.h264-OLLONBORRE\bachelor.sverige.s08e31.swedish.1080p.web.h264-ollonborre.mkv (English)
Rename episodes using [TheTVDB] with [Airdate Order]
Lookup via [The Bachelor] [bachelor sverige]
Fetching episode data for [The Bachelor]
* The Bachelor [70869] | 296 episodes | 1x01-07 .. 2x01-08 .. 3x01-09 .. 4x01-10 .. 5x01-09 .. 6x01-10 .. 7x01-09 .. 8x01-08 .. 9x01-08 .. 10x01-09 .. 11x01-10 .. 12x01-09 .. 13x01-11 .. 14x01-10 .. 15x01-12 .. 16x01-12 .. 17x01-13 .. 18x01-12 .. 19x01-13 .. 20x01-12 .. 21x01-13 .. 22x01-12 .. 23x01-12 .. 24x01-12 .. 25x01-12 .. 26x01-12 .. 27x01-11 .. 28x01-11
Fetching episode data for [Bachelor Sverige]
* Bachelor Sverige [318197] | 201 episodes | 1x01-20 .. 2x01-15 .. 3x01-14 .. 4x01-23 .. 5x01-13 .. 6x01-40 .. 7x01-40 .. 8x01-36
* The Bachelor [70869] | 296 episodes | 1x01-07 .. 2x01-08 .. 3x01-09 .. 4x01-10 .. 5x01-09 .. 6x01-10 .. 7x01-09 .. 8x01-08 .. 9x01-08 .. 10x01-09 .. 11x01-10 .. 12x01-09 .. 13x01-11 .. 14x01-10 .. 15x01-12 .. 16x01-12 .. 17x01-13 .. 18x01-12 .. 19x01-13 .. 20x01-12 .. 21x01-13 .. 22x01-12 .. 23x01-12 .. 24x01-12 .. 25x01-12 .. 26x01-12 .. 27x01-11 .. 28x01-11
Multiple options for ambiguous file path: C:\TV-IN\TV\Bachelor.Sverige.S08E31.SWEDiSH.1080p.WEB.h264-OLLONBORRE\bachelor.sverige.s08e31.swedish.1080p.web.h264-ollonborre.mkv: [The Bachelor, Bachelor Sverige]
* Consider using -non-strict to enable advanced auto-selection
* Consider using --filter "id in [70869]" or --q "The Bachelor" to select one specific series
* Consider using --mode interactive to enable interactive mode
Failed to identify or process any files
And that I should use --filter or --q to find the correct one.

Code: Select all

* Consider using --filter "id in [70869]" or --q "The Bachelor" to select one specific series
When looking at TheTVDB, the correct ID for Bachelor Sverige is 318197

Code: Select all

https://www.thetvdb.com/series/318197-show
So I then add the --q argument to my arg.txt file

Code: Select all

movieFormat=O:/{vf =~ /2160p|4K/ ? '4K' : genres =~ /Family|Children|Animation/ ? 'Barnfilm' : 'X264-10'}/{n.upperInitial()} ({y})/{n.upperInitial()} ({y})
seriesFormat=O:/{genres =~ /Children/ ? 'Barn-TV' : 'TV-12'}/{n.upperInitial()}/S{s.pad(2)}/{n.upperInitial()} - {s00e00} - {t}
seriesDB=TheTVDB
movieDB=TheMovieDB
--q "Bachelor Sverige"
And this is what is returned in the log file

Code: Select all

Run script [fn:amc] at [Fri Nov 15 08:22:21 CET 2024]
Parameter: movieFormat = O:/{vf =~ /2160p|4K/ ? '4K' : genres =~ /Family|Children|Animation/ ? 'Barnfilm' : 'X264-10'}/{n.upperInitial()} ({y})/{n.upperInitial()} ({y})
Parameter: seriesFormat = O:/{genres =~ /Children/ ? 'Barn-TV' : 'TV-12'}/{n.upperInitial()}/S{s.pad(2)}/{n.upperInitial()} - {s00e00} - {t}
Parameter: seriesDB = TheTVDB
Parameter: movieDB = TheMovieDB
Parameter: skipExtract = y
Parameter: excludeList = C:\TV-IN\Filebot\amc.txt
Parameter: subtitles = swe,eng
Parameter: unsorted = y
Parameter: clean = y
Parameter: plex = *****
Argument[0]: C:\TV-IN\TV
Use excludes: C:\TV-IN\Filebot\amc.txt (0)
Input: C:\TV-IN\TV\Bachelor.Sverige.S08E31.SWEDiSH.1080p.WEB.h264-OLLONBORRE\bachelor.sverige.s08e31.swedish.1080p.web.h264-ollonborre.mkv
Group files by movie or series
Group: {Series=The Bachelor (2002)} => [bachelor.sverige.s08e31.swedish.1080p.web.h264-ollonborre.mkv]
Get [Swedish] subtitles for 1 file
Looking up subtitles by hash via OpenSubtitles
No subtitles: C:\TV-IN\TV\Bachelor.Sverige.S08E31.SWEDiSH.1080p.WEB.h264-OLLONBORRE\bachelor.sverige.s08e31.swedish.1080p.web.h264-ollonborre.mkv (Swedish)
Get [English] subtitles for 1 file
Looking up subtitles by hash via OpenSubtitles
No subtitles: C:\TV-IN\TV\Bachelor.Sverige.S08E31.SWEDiSH.1080p.WEB.h264-OLLONBORRE\bachelor.sverige.s08e31.swedish.1080p.web.h264-ollonborre.mkv (English)
Rename episodes using [TheTVDB] with [Airdate Order]
Lookup via [The Bachelor] [bachelor sverige]
Fetching episode data for [The Bachelor]
* The Bachelor [70869] | 296 episodes | 1x01-07 .. 2x01-08 .. 3x01-09 .. 4x01-10 .. 5x01-09 .. 6x01-10 .. 7x01-09 .. 8x01-08 .. 9x01-08 .. 10x01-09 .. 11x01-10 .. 12x01-09 .. 13x01-11 .. 14x01-10 .. 15x01-12 .. 16x01-12 .. 17x01-13 .. 18x01-12 .. 19x01-13 .. 20x01-12 .. 21x01-13 .. 22x01-12 .. 23x01-12 .. 24x01-12 .. 25x01-12 .. 26x01-12 .. 27x01-11 .. 28x01-11
Fetching episode data for [Bachelor Sverige]
* Bachelor Sverige [318197] | 201 episodes | 1x01-20 .. 2x01-15 .. 3x01-14 .. 4x01-23 .. 5x01-13 .. 6x01-40 .. 7x01-40 .. 8x01-36
* The Bachelor [70869] | 296 episodes | 1x01-07 .. 2x01-08 .. 3x01-09 .. 4x01-10 .. 5x01-09 .. 6x01-10 .. 7x01-09 .. 8x01-08 .. 9x01-08 .. 10x01-09 .. 11x01-10 .. 12x01-09 .. 13x01-11 .. 14x01-10 .. 15x01-12 .. 16x01-12 .. 17x01-13 .. 18x01-12 .. 19x01-13 .. 20x01-12 .. 21x01-13 .. 22x01-12 .. 23x01-12 .. 24x01-12 .. 25x01-12 .. 26x01-12 .. 27x01-11 .. 28x01-11
Apply filter [--filter "id in [318197]"] on [513] options
Exclude [The Bachelor - 1x01 - Week One]
...
Exclude [Bachelor Sverige - 8x31 - 31]
...
[0] options remaining
* Consider using --filter "true" to disable your filter if your filter has unexpectedly excluded all potential matches
Failed to identify or process any files
The episode im after is excluded

Code: Select all

Exclude [Bachelor Sverige - 8x31 - 31]
So when that was not working, I instead tried to use the --filter option. I included it in my arg.txt file

Code: Select all

movieFormat=O:/{vf =~ /2160p|4K/ ? '4K' : genres =~ /Family|Children|Animation/ ? 'Barnfilm' : 'X264-10'}/{n.upperInitial()} ({y})/{n.upperInitial()} ({y})
seriesFormat=O:/{genres =~ /Children/ ? 'Barn-TV' : 'TV-12'}/{n.upperInitial()}/S{s.pad(2)}/{n.upperInitial()} - {s00e00} - {t}
seriesDB=TheTVDB
movieDB=TheMovieDB
--filter "318197"
And this is then the output in the log file

Code: Select all

Run script [fn:amc] at [Fri Nov 15 08:52:06 CET 2024]
Parameter: movieFormat = O:/{vf =~ /2160p|4K/ ? '4K' : genres =~ /Family|Children|Animation/ ? 'Barnfilm' : 'X264-10'}/{n.upperInitial()} ({y})/{n.upperInitial()} ({y})
Parameter: seriesFormat = O:/{genres =~ /Children/ ? 'Barn-TV' : 'TV-12'}/{n.upperInitial()}/S{s.pad(2)}/{n.upperInitial()} - {s00e00} - {t}
Parameter: seriesDB = TheTVDB
Parameter: movieDB = TheMovieDB
Parameter: skipExtract = y
Parameter: excludeList = C:\TV-IN\Filebot\amc.txt
Parameter: subtitles = swe,eng
Parameter: unsorted = y
Parameter: clean = y
Parameter: plex = *****
Argument[0]: C:\TV-IN\TV
Use excludes: C:\TV-IN\Filebot\amc.txt (0)
Input: C:\TV-IN\TV\Bachelor.Sverige.S08E31.SWEDiSH.1080p.WEB.h264-OLLONBORRE\bachelor.sverige.s08e31.swedish.1080p.web.h264-ollonborre.mkv
Group files by movie or series
Group: {Series=The Bachelor (2002)} => [bachelor.sverige.s08e31.swedish.1080p.web.h264-ollonborre.mkv]
Get [Swedish] subtitles for 1 file
Looking up subtitles by hash via OpenSubtitles
No subtitles: C:\TV-IN\TV\Bachelor.Sverige.S08E31.SWEDiSH.1080p.WEB.h264-OLLONBORRE\bachelor.sverige.s08e31.swedish.1080p.web.h264-ollonborre.mkv (Swedish)
Get [English] subtitles for 1 file
Looking up subtitles by hash via OpenSubtitles
No subtitles: C:\TV-IN\TV\Bachelor.Sverige.S08E31.SWEDiSH.1080p.WEB.h264-OLLONBORRE\bachelor.sverige.s08e31.swedish.1080p.web.h264-ollonborre.mkv (English)
Rename episodes using [TheTVDB] with [Airdate Order]
Lookup via [The Bachelor] [bachelor sverige]
Fetching episode data for [The Bachelor]
* The Bachelor [70869] | 296 episodes | 1x01-07 .. 2x01-08 .. 3x01-09 .. 4x01-10 .. 5x01-09 .. 6x01-10 .. 7x01-09 .. 8x01-08 .. 9x01-08 .. 10x01-09 .. 11x01-10 .. 12x01-09 .. 13x01-11 .. 14x01-10 .. 15x01-12 .. 16x01-12 .. 17x01-13 .. 18x01-12 .. 19x01-13 .. 20x01-12 .. 21x01-13 .. 22x01-12 .. 23x01-12 .. 24x01-12 .. 25x01-12 .. 26x01-12 .. 27x01-11 .. 28x01-11
Fetching episode data for [Bachelor Sverige]
* Bachelor Sverige [318197] | 201 episodes | 1x01-20 .. 2x01-15 .. 3x01-14 .. 4x01-23 .. 5x01-13 .. 6x01-40 .. 7x01-40 .. 8x01-36
* The Bachelor [70869] | 296 episodes | 1x01-07 .. 2x01-08 .. 3x01-09 .. 4x01-10 .. 5x01-09 .. 6x01-10 .. 7x01-09 .. 8x01-08 .. 9x01-08 .. 10x01-09 .. 11x01-10 .. 12x01-09 .. 13x01-11 .. 14x01-10 .. 15x01-12 .. 16x01-12 .. 17x01-13 .. 18x01-12 .. 19x01-13 .. 20x01-12 .. 21x01-13 .. 22x01-12 .. 23x01-12 .. 24x01-12 .. 25x01-12 .. 26x01-12 .. 27x01-11 .. 28x01-11
Apply filter [--filter "318197"] on [513] options
Exclude [The Bachelor - 1x01 - Week One]
...
Exclude [Bachelor Sverige - 8x30 - 30]
Exclude [Bachelor Sverige - 8x31 - 31]
Exclude [Bachelor Sverige - 8x32 - 32]
Exclude [Bachelor Sverige - 8x33 - 33]
Exclude [Bachelor Sverige - 8x34 - 34]
Exclude [Bachelor Sverige - 8x35 - 35]
Exclude [Bachelor Sverige - 8x36 - 36]
[0] options remaining
* Consider using --filter "true" to disable your filter if your filter has unexpectedly excluded all potential matches
Failed to identify or process any files
Its still excluding the episode that it should match against.

Code: Select all

Exclude [Bachelor Sverige - 8x31 - 31]
When matching the episode in the GUI, it finds the correct episode directly.
https://imgur.com/a/BETvhjE

What im I missing here? Please push me in the right direction.

Thanks!

Re: Using filter to exclude and handle ambiguous file

Posted: 15 Nov 2024, 08:34
by rednoah
b0ssem wrote: 15 Nov 2024, 08:11

Code: Select all

* Consider using -non-strict to enable advanced auto-selection
* Consider using --filter "id in [70869]" or --q "The Bachelor" to select one specific series
* Consider using --mode interactive to enable interactive mode
:idea: The built-in help gives you 3 possible solutions. I recommend using the first one.



:idea: -non-strict mode works by default:

Console Output: Select all

$ filebot -rename *.mkv --db TheTVDB -non-strict --action TEST --log INFO
[TEST] from [bachelor.sverige.s08e31.swedish.1080p.web.h264-ollonborre.mkv] to [Bachelor Sverige - 8x31 - 31.mkv]
NOTE: The GUI uses -non-strict mode by default. All amc script usage examples specify the -non-strict flag.



:idea: You can use the --q option like so:

Console Output: Select all

$ filebot -rename *.mkv --db TheTVDB --q "Bachelor Sverige" --action TEST --log INFO
[TEST] from [bachelor.sverige.s08e31.swedish.1080p.web.h264-ollonborre.mkv] to [Bachelor Sverige - 8x31 - 31.mkv]

Console Output: Select all

$ filebot -rename *.mkv --db TheTVDB --q 318197 --action TEST --log INFO
[TEST] from [bachelor.sverige.s08e31.swedish.1080p.web.h264-ollonborre.mkv] to [Bachelor Sverige - 8x31 - 31.mkv]
NOTE: Manually specifying the series name / series ID via the --q option is less suitable for unattended automation for obvious reasons.



:idea: You can use the --filter option like so:

Console Output: Select all

$ filebot -rename *.mkv --db TheTVDB --filter "n ==~ /Bachelor Sverige/" --action TEST --log INFO
[TEST] from [bachelor.sverige.s08e31.swedish.1080p.web.h264-ollonborre.mkv] to [Bachelor Sverige - 8x31 - 31.mkv]

Console Output: Select all

$ filebot -rename *.mkv --db TheTVDB --filter "airdate == /2024-11-13/" --action TEST --log INFO
[TEST] from [bachelor.sverige.s08e31.swedish.1080p.web.h264-ollonborre.mkv] to [Bachelor Sverige - 8x31 - 31.mkv]
NOTE: The --filter option uses your custom code to exclude options before matching on the episode level, but notably cannot add series / episode options that aren't there in the first place.






EDIT:

:!: We cannot use command-line syntax in @files. We use @file syntax to read arguments verbatim line by line precisely because we want to avoid the command-line parser which uses spaces and quotes and other symbols to interpret your command-line into a list of arguments.

YES:

Code: Select all

--q
Bachelor Sverige
NO:

Code: Select all

--q "Bachelor Sverige"
NOTE: YES on the command-line, but NO when specifying argument values line by line.

Re: Using filter to exclude and handle ambiguous file

Posted: 15 Nov 2024, 09:06
by b0ssem
:idea: The built-in help gives you 3 possible solutions. I recommend using the first one.
I have tried this, but I get issues with multiple tv shows and the renaming sometimes goes wrong. Thats why Im using strict and most of the times it works good.

EDIT:

:!: We cannot use command-line syntax in @files. We use @file syntax to read arguments verbatim line by line precisely because we want to avoid the command-line parser which uses spaces and quotes and other symbols to interpret your command-line into a list of arguments.

YES:

Code: Select all

--q
Bachelor Sverige
NO:

Code: Select all

--q "Bachelor Sverige"
NOTE: YES on the command-line, but NO when specifying argument values line by line.
If I then understand this correct, I can add the filter syntax to my arguments file and everytime this show needs to be renamed, it will go by that ID and match? Or will ALL files try to match to that filter?

Code: Select all

movieFormat=O:/{vf =~ /2160p|4K/ ? '4K' : genres =~ /Family|Children|Animation/ ? 'Barnfilm' : 'X264-10'}/{n.upperInitial()} ({y})/{n.upperInitial()} ({y})
seriesFormat=O:/{genres =~ /Children/ ? 'Barn-TV' : 'TV-12'}/{n.upperInitial()}/S{s.pad(2)}/{n.upperInitial()} - {s00e00} - {t}
seriesDB=TheTVDB
movieDB=TheMovieDB
--filter 
"id in [318197]"
EDIT:

My current script

Code: Select all

filebot -script fn:amc --output C:\TV-IN\Filebot --action move --def @C:\TV-IN\Filebot\arg.txt C:\TV-IN\TV\ --log-file C:\TV-IN\Filebot\amc.log --def skipExtract=y --def excludeList=C:\TV-IN\Filebot\amc.txt --def subtitles=swe,eng --lang swe --conflict auto --def unsorted=y --def clean=y --filter "age < 365" --def plex=192.168.50.199:XXX
and my arg.txt

Code: Select all

movieFormat=O:/{vf =~ /2160p|4K/ ? '4K' : genres =~ /Family|Children|Animation/ ? 'Barnfilm' : 'X264-10'}/{n.upperInitial()} ({y})/{n.upperInitial()} ({y})
seriesFormat=O:/{genres =~ /Children/ ? 'Barn-TV' : 'TV-12'}/{n.upperInitial()}/S{s.pad(2)}/{n.upperInitial()} - {s00e00} - {t}
seriesDB=TheTVDB
movieDB=TheMovieDB

Re: Using filter to exclude and handle ambiguous file

Posted: 15 Nov 2024, 11:25
by rednoah
This command-line usage:

Shell: Select all

--filter "id in [318197]"
is equivalent to this @file usage:

Code: Select all

--filter
id in [318197]
:!: --filter "id in [318197]" is a bad idea for unattended automation since it will prevent you from processing any episode from any TV Series that is not Series 318197. So you would have to collect all the IDs of all the shows you plan to process and add that information to your --filter and then maintain that list over time. There are some who do it that, but I wouldn't do it that way.


:idea: --filter "age < 365" means that you plan on exclusively processing episodes that have aired within the last 365 days. That does not resolve this issue in this particular case since multiple Bachelor shows are currently airing. If you add -non-strict as well then it'll work, because -non-strict is what makes it work. It will prevent mismatches from older TV Shows though, at the cost of not being able to process older TV Shows at all.

Re: Using filter to exclude and handle ambiguous file

Posted: 15 Nov 2024, 12:40
by b0ssem
:idea: --filter "age < 365" means that you plan on exclusively processing episodes that have aired within the last 365 days. That does not resolve this issue in this particular case since multiple Bachelor shows are currently airing. If you add -non-strict as well then it'll work, because -non-strict is what makes it work. It will prevent mismatches from older TV Shows though, at the cost of not being able to process older TV Shows at all.
Thanks! This is the solution im going with now. I set the days to 90 to be even more slimmed in what it can match with. Most of the shows that come in are currently airing, so it should be fine. Everything else that is older than 90 days I can just handle through the GUI whenever its needed. Thanks a lot for all of your input. Very helpful!