01x35-01x36 Multi-Episode Naming

All about user-defined episode / movie / file name format expressions
in10se
Posts: 18
Joined: 16 Nov 2018, 07:53

01x35-01x36 Multi-Episode Naming

Post by in10se »

hey guys, I am a proud paying member of Filebot!

i love this tool and use it for years now. Thank you guys so much for your effort and work!

this is my code for episodes:

Code: Select all

//q:/Renaming and Tagging/C-S/ENG/{n.replaceAll(/:/, " -").replaceAll(/ü/, "ue").replaceAll(/Ö/, "Oe").replaceAll(/Ü/, "Ue").replaceAll(/Ä/, "Ae").replaceAll(/ä/, "ae").replaceAll(/ö/, "oe").replaceAll(/[`´‘’ʻ]/, "'").replaceAll(/[!?.]+$/, "")}/Season {s.pad(2)} (Eng)/{n.replaceAll(/:/, " -").replaceAll(/ü/, "ue").replaceAll(/ä/, "ae").replaceAll(/ö/, "oe").replaceAll(/Ö/, "Oe").replaceAll(/Ü/, "Ue").replaceAll(/Ä/, "Ae").replaceAll(/[`´‘’ʻ]/, "'").replaceAll(/[!?.]+$/, "")} - {s.pad(2)}x{es*.pad(2).join('-').replaceAll("null", {episode.special ? 'Special '+special.pad(2):''})} - {t.replaceAll(/[`´‘’ʻ]/, "'").replaceAll(/ü/, "ue").replaceAll(/ä/, "ae").replaceAll(/Ö/, "Oe").replaceAll(/Ü/, "Ue").replaceAll(/Ä/, "Ae").replaceAll(/ö/, "oe").replaceAll(/[!?.]+$/, "").replaceAll(/:/, " -")} [{airdate}] ({vc}) ({ac}) ({vf})
with multi-episodes it will look like that:

Hey Arnold - 01x35-36 - Magic Show & 24 Hours To Live [1997-02-03] (XviD) (MP3) (480p)

but I want it to look like that:

Hey Arnold - 01x35-01x36 - Magic Show & 24 Hours To Live [1997-02-03] (XviD) (MP3) (480p)


so instead of "01x35-36" it shall do "01x35-01x36". Can someone help me with the change of the code? I am so bad at it!

Thank you so much!
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Multi-Episode Naming

Post by rednoah »

This will give you a 01x01 value for each episode object that is part of the multi-episode object currently being formatted:

Code: Select all

{episodes.collect{ [it.season, it.episode]*.pad(2).join('x') }.join('-')}
:idea: Please read the FAQ and How to Request Help.
in10se
Posts: 18
Joined: 16 Nov 2018, 07:53

Re: 01x35-01x36 Multi-Episode Naming

Post by in10se »

thank you so much rednoah for your answer! Shall I put this code at the beginning or at the end, or do I need to replace it with one part?
in10se
Posts: 18
Joined: 16 Nov 2018, 07:53

Re: 01x35-01x36 Multi-Episode Naming

Post by in10se »

I tried to replace it or implement it, but it says "syntax error". i know the problem sits in front of the pc, but I am so unfamiliar with those codes. How can I implement your code into mine above?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: 01x35-01x36 Multi-Episode Naming

Post by rednoah »

Your code is complex and unreadable. My tip is to separate each {expression} into it's own line, so you can easily add a {expression} somewhere, without having to look or modify any of the other {expression} parts that make up your format.

e.g.

Code: Select all

{n}
 - {episodes.collect{ [it.season, it.episode]*.pad(2).join('x') }.join('-')}
 - {t}
[{airdate}]
({vc})
({ac})
({vf})
:idea: Please read the FAQ and How to Request Help.
in10se
Posts: 18
Joined: 16 Nov 2018, 07:53

Re: 01x35-01x36 Multi-Episode Naming

Post by in10se »

ok, thanks, thats a nice tipp! will check for it
in10se
Posts: 18
Joined: 16 Nov 2018, 07:53

Re: 01x35-01x36 Multi-Episode Naming

Post by in10se »

this code

Code: Select all

{n.replaceAll(/:/, " -").replaceAll(/ü/, "ue").replaceAll(/Ö/, "Oe").replaceAll(/Ü/, "Ue").replaceAll(/Ä/, "Ae").replaceAll(/ä/, "ae").replaceAll(/ö/, "oe").replaceAll(/[`´‘’ʻ]/, "'").replaceAll(/[!?.]+$/, "")}
makes it so long and complex. It just does for every renaming, it changes the ü to ue, the ö to oe, the Ü to UE, the Ö to OE etc.


And this repeats in the code 3 times. Is there a way to make this shorter and easier?
in10se
Posts: 18
Joined: 16 Nov 2018, 07:53

Re: 01x35-01x36 Multi-Episode Naming

Post by in10se »

Also, how can I make, if the episode is a special, that it names it to this format:

Code: Select all

\Season 00\Hey Arnold! - 00x04 - Titlenameoftheepisode.avi
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: 01x35-01x36 Multi-Episode Naming

Post by rednoah »

1.
You could use n.ascii() to deal with the Umlauts but that might not give you the replacements you want.

Code: Select all

n.ascii()
:idea: You could also just not do this. Modern computers have generally no problem with Unicode characters.


2.
You could check if it's a special, and then do different things accordingly:

Code: Select all

regular ? episodes.collect{ [it.season, it.episode]*.pad(2).join('x') }.join('-') : '00x'+e.pad(2)
:idea: Please read the FAQ and How to Request Help.
in10se
Posts: 18
Joined: 16 Nov 2018, 07:53

Re: 01x35-01x36 Multi-Episode Naming

Post by in10se »

thank you for your help rednoah, I will try it out, still running into a lot of problems with it. I am just not experienced in it. I will read a bit into it and report again if I cant solve it.

Thank you so much!
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: 01x35-01x36 Multi-Episode Naming

Post by rednoah »

Each and every {} expression is independent, and each expressions usually consists of code blocks that can be tested independently. Just start with small parts, test them, and then combine them into larger ones, test them, and repeat. It’s important to start small and understand the small pieces, and then build up from there. ;)
:idea: Please read the FAQ and How to Request Help.
in10se
Posts: 18
Joined: 16 Nov 2018, 07:53

Re: 01x35-01x36 Multi-Episode Naming

Post by in10se »

Hey my friend. Easier said than done for me :(. I am trying now since an hour. This is my code:

//q:/Renaming and Tagging/C-S/ENG/{n}/Season {s.pad(2)} (Eng)/{n} - {episodes.collect{ [it.season, it.episode]*.pad(2).join('e') .replaceAll("null", {episode.special ? '00'+special.pad(2):''})}.join('-s')} - {t} [{airdate}] ({vc}) ({ac}) ({vf})

it got shorter, thanks to you.

It works perfect for multiple episodes, but still has problems with specials. This is the result:

...\River Monsters - 0001e0001 - Killer Catfish - Two Hour Special...

But I want to look it like that for every special:

..\River Monsters - s00e01 - Killer Catfish...
..\River Monsters - s00e02 - another special...

what am I missing?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: 01x35-01x36 Multi-Episode Naming

Post by rednoah »

1.
Did you check if River Monsters - 0001e0001 - Killer Catfish - Two Hour Special is identified as special in the first place? File River Monsters - 0001e0001 - Killer Catfish - Two Hour Special.mkv gives me River Monsters - S01E02 - Killer Catfish as match.


2.
Changing the numeric pattern to something more sensible like River Monsters - S00E01 - Killer Catfish - Two Hour Special allows me to get the match we want, i.e. River Monsters - S00E01 - Killer Catfish - Two Hour Special Cut.

Now that we have the right match, we can test our format.

This works for a normal episode / multi-episode:

Code: Select all

episodes.collect{ [it.season, it.episode]*.pad(2).join('x') }.join('-')
This works for single-episode specials:

Code: Select all

'00x'+special.pad(2)
The regular or episode.special bindings allow us to check if the current episode object is a special.

Now we just combine the to with a if-then-else and here we go:

Code: Select all

regular ? episodes.collect{ [it.season, it.episode]*.pad(2).join('x') }.join('-') : '00x'+special.pad(2)
This is the Groovy code, which we must enclose in {...} if we want to use it in a format expression.

:idea: Keep in mind that the outermost {...} delimits the FileBot / Groovy expression, while any {...} inside that is just Groovy code, which means these {...} are interpreted completely differently: viewtopic.php?f=5&t=1895


3.
Lastly, I'm just gonna give you a copy & paste solution, but it's best to try to come up with this yourself, so you really grasp how things work. ;)

Code: Select all

Q:/Renaming and Tagging/C-S/ENG
/{n}
/Season {s.pad(2)} (Eng)
/{n}
 - {regular ? episodes.collect{ [it.season, it.episode]*.pad(2).join('x') }.join('-') : '00x'+special.pad(2)}
 - {t}
 [{airdate}]
 ({vc})
 ({ac})
 ({vf})
:idea: Please read the FAQ and How to Request Help.
in10se
Posts: 18
Joined: 16 Nov 2018, 07:53

Re: 01x35-01x36 Multi-Episode Naming

Post by in10se »

Damn, this code is sexy. I know its weird to say it, but It looks perfect! Thank you so much for your help.

I would like to donate a bit for your helpful explanations. Now I understood the codes! Do you still have a donation link? I already purchased my life-time, but want to give you a bit out of respect for your effort!

Thank you
in10se
Posts: 18
Joined: 16 Nov 2018, 07:53

Re: 01x35-01x36 Multi-Episode Naming

Post by in10se »

One problem I have with the code. It works for multi-episodes, but only for Season 1, With other seasons it has problems, as you can see here:

https://ibb.co/crafjf
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: 01x35-01x36 Multi-Episode Naming

Post by rednoah »

You can always run a few tests (e.g. by pressing F7 to copy debug data) to figure out what we're dealing with.

As mentioned previously, you first need to ask yourself, is it a match problem? or a formatting problem? Since the format works for the first few episodes, it's likely the latter.

For me, File Garfield & Friends - 02x01-02x02-02x03 does get correctly matched to Multi-Episode Garfield & Friends - 2x01 & 2x02 & 2x03 - Pest of a Guest & The Impractical Joker & Fat and Furry and so the rest works as expected. Not idea why it's not working for you. Try a few simple test cases until you find a key factor that makes it not work for you.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: 01x35-01x36 Multi-Episode Naming

Post by kim »

Only the episodes in the file name will be added, e.g. name.s01e01-03.ext will not include episode 2.
https://kodi.wiki/view/Naming_video_fil ... i-Episodes
vs
(e.g. “Heroes s04e01-e03.mkv” starts with episode 1 and ends with episode 3).
https://support.plex.tv/articles/200220 ... -tv-shows/

so.... We need a

Code: Select all

{kodi}
same with

Code: Select all

{s00e00}
and

Code: Select all

{sxe}
KODI way

Code: Select all

{
regular ? episodes.collect{ 'S'+[it.season, it.episode]*.pad(2).join('E') }.join('-') : episodes.collect{ ['S00',it.special]*.pad(2).join('E') }.join('-')
}
or

Code: Select all

{
regular ? episodes.collect{ [it.season, it.episode.pad(2)].join('x') }.join('-') : episodes.collect{ ['0', it.special.pad(2)].join('x') }.join('-')
}
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: 01x35-01x36 Multi-Episode Naming

Post by rednoah »

I'm pretty sure that {plex} works for Kodi just as well. So you could just use {plex} and call it a day. I know the docs say otherwise, but are you sure it doesn't just work? Plenty of folks here use Kodi, and somehow it hasn't come up yet.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: 01x35-01x36 Multi-Episode Naming

Post by kim »

I just tested with in KODI 17.6
Firefly.S01E02-E04
I can confirm it DOES NOT WORK
KODI only sees ep 2 and 4 NOT ep 3

Change file to e.g.
Firefly.S01E02-E03-E04
now KODI shows all 3

if you make plex do like KODI wants it then maybe plex can use same format, can anyone confirm this ?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: 01x35-01x36 Multi-Episode Naming

Post by rednoah »

I suppose it is time for a new {kodi} binding. I'll make it happen for next release.

:?: Any other notable differences between {plex} and the proposed {kodi} that I should know about?
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: 01x35-01x36 Multi-Episode Naming

Post by kim »

Don't think so, but what about, if 3+ multi episode then KODI cant use it ?

Code: Select all

{s00e00}
and

Code: Select all

{sxe}
yes, this is a corner case, but...
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: 01x35-01x36 Multi-Episode Naming

Post by rednoah »

Pretty much, but for {s00e00} and {sxe} I'm not inclined to add addition bindings to cover this particular corner case, since in the future you'll either use {kodi} or copy & paste format code from this thread if you just want the numbers.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: 01x35-01x36 Multi-Episode Naming

Post by kim »

Maybe a poll:

Do you want all episode numbers in the filename ?
e.g. 1x02-03-04
or
keep it like it is now and only show from-to e.g. 1x02-04
in10se
Posts: 18
Joined: 16 Nov 2018, 07:53

Re: 01x35-01x36 Multi-Episode Naming

Post by in10se »

Hi Kim,

Ok, I will check what you wrote. Still dont understand it totally, but hopefully will see through it some day.

But for me, KODI only shows all episodes if I name it exactly like that: S01E02-S01E03-S01E04

if I name it S01E01-E02-E03 "media Companion" gets it right, writes it correctly to the nfo file, but in Kodi I dont see any episode at all. Most of the times they are just in "Season -1" and not shown there.

But need to check which Kodi Version I have, since I am using a OSCM Vero4K, need to check how to update Kodi there...
in10se
Posts: 18
Joined: 16 Nov 2018, 07:53

Re: 01x35-01x36 Multi-Episode Naming

Post by in10se »

I used your Code from "Kodi" Kim, and I get same probems:

https://ibb.co/c9TZUf

something on my system or with my app doesnt work correctly.

How can I check which version of filebot I have?

In the picture they are named exactly the same way and still some it recognized and some not.

But Media Companion realized them all the same way. So I just change the name manually and Kodi an Media Companion make it right.

Dont know why it doesnt work with my filebot

Thats the code I used:

Code: Select all

Q:/Renaming and Tagging/C-S/ENG
/{n}
/Season {s.pad(2)} (Eng)
/{n}
 - {regular ? episodes.collect{ 'S'+[it.season, it.episode]*.pad(2).join('E') }.join('-') : episodes.collect{ ['S00',it.special]*.pad(2).join('E') }.join('-')
}

 - {t}
 [{airdate}]
 ({vc})
 ({ac})
 ({vf})
Post Reply