Page 1 of 1

Can we query animelist(s) within groovy script using filebot methods?

Posted: 09 Sep 2020, 15:22
by rv23
Can we query the Animelists within a groovy script directly?

Non-strict looks to frequently be required to match most anime *i* am downloading, which is fine except there is a decent number of times where the match is not even the correct series AND the "correct" series name is part of the filename.

So I'd like to write a script that tries to guess the "correct" series name, and one of the data points I'd like to reference is the Anime List (Scud-Lee's specifically).
If filebot provides a method for directly interfacing/searching the list then I'd use that (no need to recreate the wheel unless I need too), if not then I'll have to do that myself :)

I've found the TheTVDB.search(query, locale) and AniDB.search(query, locale) methods while searching the filebot scripts (couldn't locate these aliases in the docs, so hopefully they are not undocumented/unsupported methods).

Here are two examples of a series which frequently when using non-strict has a good chance of not matching the series at all (and rarely matches without non-strict)

Code: Select all

2020-07-25T19:53:51Z: [MOVE] from [Z:\1-InboundRaw.PreSort\anime\[Erai-raws] Maou Gakuin no Futekigousha - 04 [720p][Multiple Subtitle].mkv] to [Z:\1-InitialSort\2020_rerelease\Kyo Kara Maoh! - God () Save Our King! [anidb-1677]\[Erai-raws] Maou Gakuin no Futekigousha - 04 [720p][Multiple Subtitle].mkv]
2020-07-25T19:53:51Z: [MOVE] from [Z:\1-InboundRaw.PreSort\anime\[HorribleSubs] Maou Gakuin no Futekigousha - 04 [720p].mkv] to [Z:\1-InitialSort\2019\summer\Demon Lord, Retry! [anidb-14391]\[HorribleSubs] Maou Gakuin no Futekigousha - 04 [720p].mkv]
And the name (Maou Gakuin no Futekigousha) is an alias/shortname in both AniDB and TheTVDB ...

And while it's ONE of the series fetched, it's common for a series mismatch ..

Code: Select all

2020-07-25T19:53:51Z: Auto-detected query: [Maou, maou gakuin no futekigousha]
2020-07-25T19:53:51Z: Fetching episode data for [Kyou kara Maou!]
2020-07-25T19:53:51Z: Fetching episode data for [Maou Dante]
2020-07-25T19:53:51Z: Fetching episode data for [Maou-sama, Retry!]
2020-07-25T19:53:51Z: Fetching episode data for [Maou-jou de Oyasumi]
2020-07-25T19:53:51Z: Fetching episode data for [Maou Gakuin no Futekigousha: Shijou Saikyou no Maou no Shiso, Tensei Shite Shison-tachi no Gakkou e Kayou]
So I want to try automating the renaming specifically for Anime, where I restrict the episode data to a single series in hopes of matching at least the right series (wrong season happens, but that's less important then at least matching the right series)..

While I can get a "series name" from the file, and I can also try searching TheTVDB/AniDB for matches, I'd like to be able to query the AnimeList for cross references, aliases etc so I can increase the accuracy of the query I send to the renamer ..

Thanks.

Re: Can we query animelist(s) within groovy script using filebot methods?

Posted: 09 Sep 2020, 16:07
by rednoah
If common alias names aren't yet added for new shows, then that could indeed be an issue. Either "Maou Gakuin no Futekigousha: Shijou Saikyou no Maou no Shiso, Tensei Shite Shison-tachi no Gakkou e Kayou" or "The Misfit of Demon King Academy History`s Strongest Demon King Reincarnates and Goes to School with His Descendants" make for a huge Edit Distance, but once "Maou Gakuin no Futekigousha" is added as known alias, things are likely to work out.



In this particular case, I'd use the newly added --q expression feature:
viewtopic.php?t=12043

Code: Select all

--q "{fn.before(' - ').after('] ')}"


Alternatively, or in addition, one might consider using --filter in combination with a whitelist of allowed Anime to further restrict which Anime are to be considered for matching:
viewtopic.php?t=2127

Code: Select all

--filter "n in lines('/path/to/anime-names.txt')"


Test Case:

Code: Select all

$ filebot -rename *.mkv --db AniDB -non-strict --q "{fn.before(' - ').after('] ')}" --action TEST --log INFO
[TEST] from [[Erai-raws] Maou Gakuin no Futekigousha - 04 [720p][Multiple Subtitle].mkv] to [The Misfit of Demon King Academy History`s Strongest Demon King Reincarnates and Goes to School with His Descendants - 04 - 15th Birthday.mkv]

Code: Select all

$ filebot -rename *.mp4 --db AniDB -non-strict --filter "id in [15131]" --action TEST --log INFO
[TEST] from [[HorribleSubs] Maou Gakuin no Futekigousha - 04 [720p].mp4] to [The Misfit of Demon King Academy History`s Strongest Demon King Reincarnates and Goes to School with His Descendants - 04 - 15th Birthday.mp4]