Anime - absolute numbering with eng & jap title and more

All about user-defined episode / movie / file name format expressions
Post Reply
User avatar
Ithiel
Power² User
Posts: 204
Joined: 11 Jul 2013, 14:58

Anime - absolute numbering with eng & jap title and more

Post by Ithiel »

Hi guys,

I've been working on a rather complicated naming scheme, and would like some input on it. It works as follows...

Folders:
  • - Series name in English with the Roman Japanese name in brackets (only if its different)
    - Lists the year and, if available, the certification rating
    - Moves "The " to the end as ", The"
    - Replaces funky characters
Files:
  • - Uses the English name in the episode titles
    - Moves "The " to the end as ", The"
    - References absolute episode number forced to 2 digits
    - Shows the episode title
    - finishes with the standard video format, video codec, audio codec (mainly to point out FLAC files), and audio channels
    - Replaces funky characters
Example:
Ambition Of Oda Nobuna, The [Oda Nobuna no Yabou] (2012)\Ambition Of Oda Nobuna, The - 01 - Nobuna And The Monkey [720p x264 AAC 2ch]

Code: Select all

{(x = n.upperInitial().lowerTrail().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*]/, " ").replaceAll(/[  ]/, " ").replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/))} {if (x != (z = net.sourceforge.filebot.WebServices.AniDB.animeTitles.find{n == it.getOfficialTitle('en')}?.primaryTitle ?: n.upperInitial().lowerTrail().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*]/, " ").replaceAll(/[  ]/, " ").replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/))) "["+z.upperInitial().lowerTrail().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*]/, " ").replaceAll(/[  ]/, " ").replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)+"] "}({y}{" $certification"})/{n.upperInitial().lowerTrail().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*]/, " ").replaceAll(/[  ]/, " ").replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)} - {absolute.pad(2)}{"Special "+special.pad(2)} - {t.upperInitial().lowerTrail().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*]/, " ").replaceAll(/[  ]/, " ")}{" ["+vf+" "+vc+" "+ac+" "+af+"]"}
I'm keen to get a few people's thoughts on this - especially if there's a way I can "summarise" that a little bit, lol

Cheers,

Ithiel
There can be only one Power² User
User avatar
rednoah
The Source
Posts: 22975
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Anime - absolute numbering with eng & jap title and more

Post by rednoah »

This is how I'd write it:

Code: Select all

{norm = {it.upperInitial().lowerTrail().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ").replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)}; def np = net.sourceforge.filebot.WebServices.AniDB.animeTitles.find{n == it.getOfficialTitle('en')}?.primaryTitle; np == null || norm(n) == norm(np) ? norm(n) : norm(n)+' ['+norm(np)+']'} ({y}{" $certification"})/{norm(n)} - {absolute.pad(2)}{'Special '+special.pad(2)} - {norm(t)} {" [$vf $vc $ac $af]"}
Should be exactly the same. Made the cleanup code a Closure and reuse it, simlified the white-space regex a bit and replaced the last part with a GString expression.
:idea: Please read the FAQ and How to Request Help.
User avatar
Ithiel
Power² User
Posts: 204
Joined: 11 Jul 2013, 14:58

Re: Anime - absolute numbering with eng & jap title and more

Post by Ithiel »

Wowzer, that is so much easier to read than my original muck. lol.

Granted, mine was basically just working off what is on filebot.net/naming.html, a few random bits I stumbled on in the forum, and a bunch of trial and error - so the fact that I got mine working at all is practically a miracle >.<

I've swapped over to that code, and all seems well and good - thanks, this is going to be so much easier to tweak for any future variations I need :-)
There can be only one Power² User
User avatar
rednoah
The Source
Posts: 22975
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Anime - absolute numbering with eng & jap title and more

Post by rednoah »

With the latest revision you can simplify the first part with the new {primaryTitle} binding:

Code: Select all

{norm = {it.upperInitial().lowerTrail().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ").replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)}; norm(n)}{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'}
:idea: Please read the FAQ and How to Request Help.
User avatar
Ithiel
Power² User
Posts: 204
Joined: 11 Jul 2013, 14:58

Re: Anime - absolute numbering with eng & jap title and more

Post by Ithiel »

Cool.... so... that would become this, correct?

Code: Select all

{norm = {it.upperInitial().lowerTrail().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ").replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)}; norm(n)}{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'} ({y}{" $certification"})/{norm(n)} - {absolute.pad(2)}{'Special '+special.pad(2)} - {norm(t)}{" [$vf $vc $ac $af]"}
Edit: forgot the code tags
There can be only one Power² User
User avatar
rednoah
The Source
Posts: 22975
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Anime - absolute numbering with eng & jap title and more

Post by rednoah »

That should work. You can grab the latest jar and try it. Check the FAQ.
:idea: Please read the FAQ and How to Request Help.
Retexks
Posts: 7
Joined: 31 Aug 2013, 01:21

Re: Anime - absolute numbering with eng & jap title and more

Post by Retexks »

Is it possible to do this using the TVDB rather than just Anidb. I know the TVDB's API supports alias names (http://forums.thetvdb.com/viewtopic.php?f=17&t=13323)
I've searched the forum, naming scheme and FAQ however I can't find an Alias field. The functionality i'm looking for would be along the lines of

{n} ({n.alias})/n - s00e00 - t

However things are easier said than done, what code would I need to use to grab the "AliasNames" from TVDB (http://thetvdb.com/api/GetSeries.php?se ... nguage=all)
User avatar
rednoah
The Source
Posts: 22975
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Anime - absolute numbering with eng & jap title and more

Post by rednoah »

With the newer revisions there is {primaryTitle} which will get you the TheTVDB English Title or AniDB Primary Title respectively regardless of your language preferences.
:idea: Please read the FAQ and How to Request Help.
Retexks
Posts: 7
Joined: 31 Aug 2013, 01:21

Re: Anime - absolute numbering with eng & jap title and more

Post by Retexks »

I understood the {primaryTitle}, I'm wondering if there is a {secondaryTitle} option
User avatar
rednoah
The Source
Posts: 22975
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Anime - absolute numbering with eng & jap title and more

Post by rednoah »

There's {n} and {primaryTitle} now. As far as I understand there are no alias lists in the DBs, just localized titles for different languages.
:idea: Please read the FAQ and How to Request Help.
Retexks
Posts: 7
Joined: 31 Aug 2013, 01:21

Re: Anime - absolute numbering with eng & jap title and more

Post by Retexks »

As I stated in the two links I provided above there is a "AliasNames" field provided by TVDB.
example; http://thetvdb.com/api/GetSeries.php?se ... nguage=all
using {n} and {primaryTitle} from the series above will only return (A Certain Magical Index)
if I search episodes with (To Aru Majutsu no Index) it will return (A Certain Magical Index)
I'm unsure if filebot can scrap the "AliasNames" field from TVDB, so I can't get a name folders;
A Certain Magical Index (To Aru Majutsu no Index)
as doing {n} ({primaryTitle}) will just return; A Certain Magical Index (A Certain Magical Index), using TVDB
User avatar
rednoah
The Source
Posts: 22975
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Anime - absolute numbering with eng & jap title and more

Post by rednoah »

Alright, that <AliasNames> element is new. Maybe I'll add support at some point in the future.

Though u can access the xml api directy with groovy code in the format in the meanwhile.
:idea: Please read the FAQ and How to Request Help.
Retexks
Posts: 7
Joined: 31 Aug 2013, 01:21

Re: Anime - absolute numbering with eng & jap title and more

Post by Retexks »

Cool now I need to go off and teach myself the groovy code
User avatar
Ithiel
Power² User
Posts: 204
Joined: 11 Jul 2013, 14:58

Re: Anime - absolute numbering with eng & jap title and more

Post by Ithiel »

For the absolute numbering, I tend to limit it to 2 digits for shows <100 episodes (which is most things), and then 3 digits for shows with over 100 episodes (Naruto, Bleach, etc..).

i.e. Two digits:

Code: Select all

{absolute.pad(2)}{'Special '+special.pad(2)}
Three Digits:

Code: Select all

{absolute.pad(3)}{'Special '+special.pad(3)}
The problem is that this means having to toggle between them depending on the show I'm renaming...

Is there any way to have it check if the highest episode number or the episode count is less than 100, then use 2 digits, or if it is more than 99, then use 3 digits?
There can be only one Power² User
User avatar
rednoah
The Source
Posts: 22975
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Anime - absolute numbering with eng & jap title and more

Post by rednoah »

You could try this:

Code: Select all

{absolute.pad(episodelist.size() < 100 ? 2 : 3)}
:idea: Please read the FAQ and How to Request Help.
User avatar
Ithiel
Power² User
Posts: 204
Joined: 11 Jul 2013, 14:58

Re: Anime - absolute numbering with eng & jap title and more

Post by Ithiel »

Awesome - it seems to like that :-)

Although.. wouldn't it be < 99, rather than < 100 (otherwise shows with 100 episodes wouldn't trigger it)?

Thus making it:

Code: Select all

{absolute.pad(episodelist.size() < 99 ? 2 : 3)}{'Special '+special.pad(episodelist.size() < 99 ? 2 : 3)}
There can be only one Power² User
User avatar
Ithiel
Power² User
Posts: 204
Joined: 11 Jul 2013, 14:58

Re: Anime - absolute numbering with eng & jap title and more

Post by Ithiel »

Argh... scratch that - seems there's a bit of a snag. It works for some anime, but not others :-/

Figured this out as 3: One Piece (http://anidb.net/perl-bin/animedb.pl?show=anime&aid=69)
Figured this out as 2: Nodame Cantabile (http://anidb.net/perl-bin/animedb.pl?sh ... e&aid=4691)
Didn't know what to do with this: Nodame Cantabile: Paris Hen (http://anidb.net/perl-bin/animedb.pl?sh ... e&aid=5941)

For the last one there, it doesn't show ANY episode numbers at all.

So, instead of getting this: Nodame Cantabile - Paris Hen - 01 - Lesson 1.mkv
I get this: Nodame Cantabile - Paris Hen - - Lesson 1.mkv

However when I swap back to using {absolute.pad(2)}, I get my episode number back :-/
There can be only one Power² User
User avatar
rednoah
The Source
Posts: 22975
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Anime - absolute numbering with eng & jap title and more

Post by rednoah »

try the latest jar, before it was on resolving {episodelist} against TheTVDB. The new version should use TheTVDB/AniDB depending on the original data.
:idea: Please read the FAQ and How to Request Help.
User avatar
Ithiel
Power² User
Posts: 204
Joined: 11 Jul 2013, 14:58

Re: Anime - absolute numbering with eng & jap title and more

Post by Ithiel »

lol, you must still be uploading it. I'll try again in a little bit :-)

Sourceforge has the latest build as 11 hours ago (filebot-3.8-r1949-fn20), and that build still seems to have the same issue.
There can be only one Power² User
User avatar
Ithiel
Power² User
Posts: 204
Joined: 11 Jul 2013, 14:58

Re: Anime - absolute numbering with eng & jap title and more

Post by Ithiel »

woohoo! worked like a charm :-)

Thanks mate.
There can be only one Power² User
adonisk
Posts: 4
Joined: 05 Jun 2014, 09:44

Re: Anime - absolute numbering with eng & jap title and more

Post by adonisk »

@Ithiel could you provide the final script? It seems like you guyz are sharing code snippets instead of the whole script.
User avatar
Ithiel
Power² User
Posts: 204
Joined: 11 Jul 2013, 14:58

Re: Anime - absolute numbering with eng & jap title and more

Post by Ithiel »

Hi adonisk,

Sorry I didn't see your message. You can find the complete naming schemes on GitHub via the link below:

https://github.com/CapriciousSage/schemes

They're also integrated into this context menu pack:

http://www.filebot.net/forums/viewtopic.php?f=3&t=1222

Happy hunting! :-)
There can be only one Power² User
Post Reply