Page 1 of 1

Anime - absolute numbering with eng & jap title and more

Posted: 11 Jul 2013, 15:11
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

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

Posted: 11 Jul 2013, 16:07
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.

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

Posted: 11 Jul 2013, 16:33
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 :-)

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

Posted: 14 Jul 2013, 12:09
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)+')'}

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

Posted: 15 Jul 2013, 00:22
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

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

Posted: 15 Jul 2013, 02:43
by rednoah
That should work. You can grab the latest jar and try it. Check the FAQ.

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

Posted: 31 Aug 2013, 01:58
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)

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

Posted: 31 Aug 2013, 07:24
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.

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

Posted: 31 Aug 2013, 10:31
by Retexks
I understood the {primaryTitle}, I'm wondering if there is a {secondaryTitle} option

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

Posted: 31 Aug 2013, 17:08
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.

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

Posted: 01 Sep 2013, 00:27
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

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

Posted: 01 Sep 2013, 08:35
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.

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

Posted: 01 Sep 2013, 10:51
by Retexks
Cool now I need to go off and teach myself the groovy code

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

Posted: 28 Dec 2013, 03:42
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?

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

Posted: 28 Dec 2013, 04:32
by rednoah
You could try this:

Code: Select all

{absolute.pad(episodelist.size() < 100 ? 2 : 3)}

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

Posted: 28 Dec 2013, 07:55
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)}

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

Posted: 28 Dec 2013, 08:14
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 :-/

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

Posted: 28 Dec 2013, 08:53
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.

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

Posted: 28 Dec 2013, 09:18
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.

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

Posted: 28 Dec 2013, 10:13
by Ithiel
woohoo! worked like a charm :-)

Thanks mate.

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

Posted: 05 Jun 2014, 09:50
by adonisk
@Ithiel could you provide the final script? It seems like you guyz are sharing code snippets instead of the whole script.

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

Posted: 26 Jun 2014, 06:13
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! :-)