How to deal with Anime mismatches in the amc script?

Support for Windows users
Post Reply
crawfs
Posts: 24
Joined: 01 Feb 2019, 09:26

How to deal with Anime mismatches in the amc script?

Post by crawfs »

I have a file named

Code: Select all

[SubsPlease] Shingeki no Kyojin (The Final Season) - 60 (1080p) [11F4C2A5].mkv
and it appears that the parenthesis around "The Final Season" are causing the file to be incorrectly matched, as shown:

Code: Select all

PS E:\FilebotTest\output> filebot.exe --log FINEST --lang English --action TEST --output "E:\Download"  -script fn:amc -non-strict "E:\FilebotTest" --def animeFormat="{n}\Season {s.pad(2)}\{n} - {s00e00}" --mapper AnimeList.TheTVDB
Run script [fn:amc] at [Mon Dec 14 21:31:20 AEDT 2020]
Parameter: animeFormat = {n}\Season {s.pad(2)}\{n} - {s00e00}
Argument[0]: E:\FilebotTest
Input: E:\FilebotTest\[SubsPlease] Shingeki no Kyojin (The Final Season) - 60 (1080p) [11F4C2A5].mkv
Group: {Anime=shingeki no kyojin} => [[SubsPlease] Shingeki no Kyojin (The Final Season) - 60 (1080p) [11F4C2A5].mkv]
Rename episodes using [AniDB] with [Absolute]
Lookup via [Shingeki no Kyojin]
Fetching episode data for [Shingeki no Kyojin]
Fetching episode data for [Shingeki no Kyojin Season 2]
Fetching episode data for [Shingeki no Kyojin Season 3]
Fetching episode data for [Shingeki no Kyojin OAD]
Fetching episode data for [Shingeki no Kyojin Season 3 (2019)]
Apply mapper [AnimeList.TheTVDB] on [94] episodes
...
Reverse Map [Attack on Titan - Special 22 - Lost in the Cruel World] to [Shingeki no Kyojin OAD - 08 - Lost in the Cruel World]
[TEST] from [E:\FilebotTest\[SubsPlease] Shingeki no Kyojin (The Final Season) - 60 (1080p) [11F4C2A5].mkv] to [E:\Download\Shingeki no Kyojin OAD\Season\Shingeki no Kyojin OAD - S00E22.mkv]
Processed 1 file
As shown it incorrectly matches the file to

Code: Select all

Shingeki no Kyojin OAD - S00E22.mkv
As opposed to

Code: Select all

Attack on Titan - S04E01.mkv
However when I remove the parentheses around "The Final Season" I get a different result:

Code: Select all

PS E:\FilebotTest\output> filebot.exe --log FINEST --lang English --action TEST --output "E:\Download"  -script fn:amc -non-strict "E:\FilebotTest" --def animeFormat="{n}\Season {s.pad(2)}\{n} - {s00e00}" --mapper AnimeList.TheTVDB
Run script [fn:amc] at [Mon Dec 14 21:34:38 AEDT 2020]
Parameter: animeFormat = {n}\Season {s.pad(2)}\{n} - {s00e00}
Argument[0]: E:\FilebotTest
Input: E:\FilebotTest\[SubsPlease] Shingeki no Kyojin The Final Season - 60 (1080p) [11F4C2A5].mkv
Group: {Anime=shingeki no kyojin the final season} => [[SubsPlease] Shingeki no Kyojin The Final Season - 60 (1080p) [11F4C2A5].mkv]
Rename episodes using [AniDB] with [Absolute]
Lookup via [Shingeki no Kyojin The Final Season]
Fetching episode data for [Shingeki no Kyojin: The Final Season]
Fetching episode data for [Shingeki no Kyojin Season 2]
Fetching episode data for [Shingeki no Kyojin Season 3]
Fetching episode data for [Shingeki no Kyojin Season 3 (2019)]
Fetching episode data for [Shingeki no Kyojin]
Apply mapper [AnimeList.TheTVDB] on [90] episodes
...
Reverse Map [Attack on Titan - 4x01] to [Attack on Titan Final Season - 01 - The Other Side of the Sea]
[TEST] from [E:\FilebotTest\[SubsPlease] Shingeki no Kyojin The Final Season - 60 (1080p) [11F4C2A5].mkv] to [E:\Download\Attack on Titan Final Season\Season 04\Attack on Titan Final Season - S04E01.mkv]
Processed 1 file
This gives me the result

Code: Select all

Attack on Titan Final Season - S04E01.mkv
Which is much closer to the desired outcome, albeit with "Final Season" appended to it but at least the Season/Episode combination is correct.

Not sure what it is that I'm doing wrong here but I would appreciate a push in the right direction.
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Filebot ignoring text in parentheses leading to incorrect episode naming

Post by rednoah »

You're mapping between databases multiple times (sometimes explicitly, sometimes transparently) so it's somewhat difficult to understand how things come together.


:arrow: If you just want TheTVDB SxE naming and numbering, then that should work just fine by default:

Code: Select all

filebot -rename *.mkv --db TheTVDB -non-strict --order Airdate --action TEST --log INFO
[TEST] from [[SubsPlease] Shingeki no Kyojin (The Final Season) - 60 (1080p) [11F4C2A5].mkv] to [Attack on Titan - 4x01 - The Other Side of the Sea.mkv]
:idea: Please read the FAQ and How to Request Help.
crawfs
Posts: 24
Joined: 01 Feb 2019, 09:26

Re: Filebot ignoring text in parentheses leading to incorrect episode naming

Post by crawfs »

Hm, my only concern with this is that the folder I run the filebot on has a number of arbitrary files such as movies, tv shows and anime. With this example I'd presumably have to write a script like this:

Code: Select all

filebot -rename *.mkv --db TheTVDB -non-strict --order Airdate --action TEST --log INFO

filebot -rename *.mkv --db TheMovieDB -non-strict --order Airdate --action copy --log INFO --output "path/to/renamed/files"
This also lacks an excludeList, is there no way to do this with amc? Or am I approaching this wrong?
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Filebot ignoring text in parentheses leading to incorrect episode naming

Post by rednoah »

crawfs wrote: 14 Dec 2020, 21:28 This also lacks an excludeList, is there no way to do this with amc? Or am I approaching this wrong?
Possibly, but it's just in the nature of things that things get exponentially more complex if you want to do lots of different things with a single generic algorithm. IMHO, what you're doing in the OP is definitely not an elegant approach.


If you prefer to use the amc script, and since treating this file as TV Show (as opposed to Anime which are processed against AniDB and don't have seasons) just works, the solution might be as simple as forcing TV mode for all your TV Show files. If you can, make sure to organize files into TV Shows and Movies folders before processing. Depending on your process, this may not be much extra effort, and may be as simple as selecting a label when adding downloads.
rednoah wrote: 01 Aug 2012, 13:04 Common Problems
You can (and should) force Movie / Series / Anime mode or force ignore files via labels, e.g. label as Movie to force TheMovieDB, Series to force TheTVDB, Anime to force AniDB, or other to ignore all files. Alternatively, standard folder names such as Movies / TV Shows / Anime may also be used to force a specific mode.
rednoah wrote: 01 Aug 2012, 13:04 Advanced Fine-Tuning
You can (and should) force Movie / Series / Anime mode by setting --def ut_label accordingly, and you can further define your own --filter rules to fine-tune matching to your exact needs, and avoid mismatches. For example, if one show is confused with another due to bad naming or missing data you can simply exclude the bad one, or if you only process recently aired episodes, then you could exclude episodes that have not aired recently from matching.

e.g. if you only process recently aired episodes you can virtually guarantee 100% auto-detection accuracy by adding simple filter rules such as these:

Code: Select all

--filter "age < 5" --def "ut_label=TV"
e.g. if you're a typical user, and find a simple age filter too restrictive, then this slightly augmented age filter rule might be the magic bullet that fixes all your problems:

Code: Select all

--filter "age < 5 || 5 <= model.age.min()" --def "ut_label=TV"
--filter rules are extremely flexible so more complex scenarios, such as applying certain filters only for certain labels or files, is fully supported.

Alternatively, you could also try using TheTVDB as preferred Anime database:

Code: Select all

--def animeDB=TheTVDB
:idea: Please read the FAQ and How to Request Help.
ZyFinity
Posts: 10
Joined: 28 Jan 2022, 10:25

Re: How to deal with Anime mismatches in the amc script?

Post by ZyFinity »

ZyFinity wrote: Has personal information so would like removed.
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to deal with Anime mismatches in the amc script?

Post by rednoah »

The amc script will only fetch the episode list for the top 5 results, which is unfortunately not enough to include "Shingeki no Kyojin: The Final Season (2022)" when searching for "Shingeki no Kyojin". It's an unfortunate special case. You'll likely need a special call for "Shingeki no Kyojin: The Final Season (2022)" files, or just use the GUI, because the "one-size-fits-all" solution just doesn't fit in this particular corner case.


:arrow: If you use TheTVDB / TheMovieDB::TV with Absolute Order instead of AniDB then the amc script should work out-of-the-box. The file you have just doesn't match AniDB naming and numbering at all, so if you must use AniDB, then you might have to use the GUI.
:idea: Please read the FAQ and How to Request Help.
ZyFinity
Posts: 10
Joined: 28 Jan 2022, 10:25

Re: How to deal with Anime mismatches in the amc script?

Post by ZyFinity »

Ah, is there any way for it to look for more than the top 5 results? or at least search the full name so that it shows up in the top 5 results?
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to deal with Anime mismatches in the amc script?

Post by rednoah »

Sorry, the current behaviour works for everything else, so I'm reluctant to make changes there for one specific corner case that may not generalize, a 1 step forward 3 steps back kinda thing.


:arrow: You could use a custom query expression I suppose, but that will have to be tailored to your specific use case one way or another:
viewtopic.php?t=12043

e.g. force a specific series:

Code: Select all

$ filebot -rename *.mkv --db AniDB --q 16177 -non-strict --filter "age < 7" --action TEST
[TEST] from [[SubsPlease] Shingeki no Kyojin (The Final Season) - 78 (1080p) [5AFF5292].mkv] to [Attack on Titan The Final Season (2022) - 03 - Two Brothers.mkv]


:!: Unfortunately, using --q to extract the series name with custom code does not work in this case, because our code would have to infer the 2022 which isn't part of the file name at all:

Code: Select all

$ filebot -rename *.mkv --db AniDB --q "{ fn.after(']').before('-') }" --filter "age < 7" -non-strict --action TEST
Rename episodes using [AniDB] with [Absolute]
Lookup via [Shingeki no Kyojin (The Final Season)]
Fetching episode data for [Shingeki no Kyojin: The Final Season]
...
Failure (×_×)
:arrow: The next step would be an external query.groovy file that would then codify all the rules to conjure up the AniDB series name for any given input file. Possible, probably not worth the effort to write and maintain a custom solution like that.




EDIT:

:arrow: I'd use --def ignore=Shingeki.no.Kyojin to just skip all the Shingeki no Kyojin episodes, and then process them separately with the GUI, or custom CLI commands.

e.g. a tailor-made command for each corner case that processes a specific set of files with a specific set of options will make things much easier:

Code: Select all

$ filebot -rename -r /input --file-filter "fn =~ /Shingeki.no.Kyojin/" --db AniDB --q 16177 --filter "age < 7" -non-strict --action TEST
[TEST] from [[SubsPlease] Shingeki no Kyojin (The Final Season) - 78 (1080p) [5AFF5292].mkv] to [Attack on Titan The Final Season (2022) - 03 - Two Brothers.mkv]
:idea: So you could take care of Shingeki no Kyojin episodes with a custom call first, move them away, and then call the amc script in a second step to deal with the generic everything else.
:idea: Please read the FAQ and How to Request Help.
ZyFinity
Posts: 10
Joined: 28 Jan 2022, 10:25

Re: How to deal with Anime mismatches in the amc script?

Post by ZyFinity »

Awesome, thanks. To add to this, would it in any way be possible to have the file hashed (or the hash detected within the title as most anime nowadays have the hash in the title) and lookup on anidb to find the correct match? especially since the hash database on anidb is very active and "rich"
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to deal with Anime mismatches in the amc script?

Post by rednoah »

The AniDB HTTP API does not support hash lookup, and no other database supports anything like it. Plus File I/O is extremely slow compared to just using file name / file attributes. It sure does make sense in this particularly tricky corner case, but not so much for pretty much everything else. Your input files not even named / numbered according to AniDB does suggest that [SubsPlease] doesn't care for AniDB, so hashes are less likely to exist in this case. Though someone has probably added them by now.


That said, there surely are dedicated tools (e.g. adbren.pl) that do exactly that and only that. You could just use one of those tools as a preprocessor to make the file name nice and add AniDB ID, and then use FileBot in a second pass for custom formatting as desired.
:idea: Please read the FAQ and How to Request Help.
ZyFinity
Posts: 10
Joined: 28 Jan 2022, 10:25

Re: How to deal with Anime mismatches in the amc script?

Post by ZyFinity »

yeah I think what i'll do is let amc try first, and if it fails it will send the episode to an unsorted folder where "shoko anime server" will hash and organize the files, as generally hashes get added to anidb within 24 hours of airing however its not instant like filebot would be, this should hopefully make a fairly robust solution.
ZyFinity
Posts: 10
Joined: 28 Jan 2022, 10:25

Re: How to deal with Anime mismatches in the amc script?

Post by ZyFinity »

Also sorry for being a little off topic however, how would I go about downloading only the tvdb poster associated with the anidb matched anime? i have the "artwork=y" option enabled however can't find any further documentation on how to download artwork, is there anything further that's needed
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to deal with Anime mismatches in the amc script?

Post by rednoah »

Sorry, there are no fine-grained options for --def artwork. It's either all or nothing. There's nothing you can configure / turn on / turn off / etc so there's no documentation.


:arrow: You can use --apply cover instead though:
viewtopic.php?t=11079
:idea: Please read the FAQ and How to Request Help.
Post Reply