Multipart Episodes & Help with code

All about user-defined episode / movie format expressions
Post Reply
ByteShare
Posts: 21
Joined: 13 Mar 2018, 15:38

Multipart Episodes & Help with code

Post by ByteShare » 12 Mar 2019, 16:42

Right now I'm using (simplified):

Code: Select all

{n} {episode.special?'00':s.pad(2)}x{es*.pad(2).join('-')}{fn.match(/x[0-9][0-9]\.1|x[0-9][0-9][0-9]\.1|x[0-9][0-9]\.a|x[0-9][0-9][0-9]\.a|x[0-9][0-9]a|x[0-9][0-9][0-9]a/)?'.1':''} {t}{'.'+lang}
  • I would use just {sxe} for the episode number but I can't get it to pad the season. and {s00e00} does pad and is only 1 more character but starts being more on multiepisodes (ie S01E01-E02-E03)
  • But the main question is on how to turn these functions in regular expression into one?

Code: Select all

{fn.match(/x[0-9][0-9]\.1|x[0-9][0-9][0-9]\.1|x[0-9][0-9]\.a|x[0-9][0-9][0-9]\.a|x[0-9][0-9]a|x[0-9][0-9][0-9]a/)?'.1':''}
{fn.match(/x[0-9][0-9]\.2|x[0-9][0-9][0-9]\.2|x[0-9][0-9]\.b|x[0-9][0-9][0-9]\.b|x[0-9][0-9]b|x[0-9][0-9][0-9]b/)?'.2':''}
{fn.match(/x[0-9][0-9]\.3|x[0-9][0-9][0-9]\.3|x[0-9][0-9]\.c|x[0-9][0-9][0-9]\.c|x[0-9][0-9]c|x[0-9][0-9][0-9]c/)?'.3':''}
{fn.match(/x[0-9][0-9]\.4|x[0-9][0-9][0-9]\.4|x[0-9][0-9]\.d|x[0-9][0-9][0-9]\.d|x[0-9][0-9]d|x[0-9][0-9][0-9]d/)?'.4':''}
{fn.match(/x[0-9][0-9]\.5|x[0-9][0-9][0-9]\.5|x[0-9][0-9]\.e|x[0-9][0-9][0-9]\.e|x[0-9][0-9]e|x[0-9][0-9][0-9]e/)?'.5':''}
{fn.match(/x[0-9][0-9]\.6|x[0-9][0-9][0-9]\.6|x[0-9][0-9]\.f|x[0-9][0-9][0-9]\.f|x[0-9][0-9]f|x[0-9][0-9][0-9]f/)?'.6':''}
{fn.match(/x[0-9][0-9]\.7|x[0-9][0-9][0-9]\.7|x[0-9][0-9]\.g|x[0-9][0-9][0-9]\.g|x[0-9][0-9]g|x[0-9][0-9][0-9]g/)?'.7':''}
{fn.match(/x[0-9][0-9]\.8|x[0-9][0-9][0-9]\.8|x[0-9][0-9]\.h|x[0-9][0-9][0-9]\.h|x[0-9][0-9]h|x[0-9][0-9][0-9]h/)?'.8':''}
{fn.match(/x[0-9][0-9]\.9|x[0-9][0-9][0-9]\.9|x[0-9][0-9]\.i|x[0-9][0-9][0-9]\.i|x[0-9][0-9]i|x[0-9][0-9][0-9]i/)?'.9':''}
Should be giving out puts like:
Macross Frontier 01x03.1 > Macross Frontier 01x03.1 On Your Marks
Macross Frontier 01x03.2 > Macross Frontier 01x03.2 On Your Marks
Macross Frontier 01x03.A > Macross Frontier 01x03.1 On Your Marks
Macross Frontier 01x03.B > Macross Frontier 01x03.2 On Your Marks
Macross Frontier 01x03A > Macross Frontier 01x03.1 On Your Marks
Macross Frontier 01x03B > Macross Frontier 01x03.2 On Your Marks
Extra comments:
-Something as simple as

Code: Select all

{dc > 1 ? ", Part $di" : null}
Almost gives me what I need but if I'm missing a part say I have 01x01.1 and 01x01.3 but not 01x01.2 it would name 01.3 to 01.2, which is part of the reason I don't want to mux multipart episodes together.
-I tried using "\d" to be a digit for the [0-9] but that doesn't seem to work, not that it would unify the lines of code.
-Kodi info on this (same as Plex from what I know): https://kodi.wiki/view/Naming_video_fil ... t_Episodes

User avatar
rednoah
The Source
Posts: 16758
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Multipart Episodes & Help with code

Post by rednoah » 12 Mar 2019, 17:13

If you have 01x01.1 and 01x01.3 why would you not also have 01x01.2 at that point? Seems like an extremely contrived or rare case, and writing generic code for a one-off use case that you could just do manually doesn't make sense.


But you wanna continue doing things the way you're doing things, then this example snipped might help you out a little bit:

Code: Select all

"01x03.B".match(/\d+x\d+[.]?(\w)\b/).upper().replace(A:1, B:2, C:3)
:idea: Please read the FAQ and How to Request Help.

ByteShare
Posts: 21
Joined: 13 Mar 2018, 15:38

Re: Multipart Episodes & Help with code

Post by ByteShare » 12 Mar 2019, 20:46

It is rare to get multipart episodes but 99% are from cartoons. It is even more rare that I get missing parts but generally that is because it was an anime that didn't get all of the episodes translated to english so there are actual missing episodes unless you get the original language only file...So, for the few times this comes up for me I've probably already spent too much time on this but some of it is also wanting to understand how to do this since I've tried a few times over the years and even gotten help a few times but wasn't able to figure it out.
I took the code you suggested and added just a little to it but mostly origination:

Code: Select all

{fn.match(/\d+x\d+[.]?(\w)\b/).upper().replace(A:1,B:2,C:3,D:4,E:5,F:6,G:7,H:8,I:9)}
That mostly works but only for ##x##[Letter] & ##x##.[Letter], for ##x##.# it doesn't include the .(dot) and for multiepisodes ##x##-## it include the first episode at the end ie: 00x04-05 > 00x04-054

Ignoring the long dead ends I went down (about 3 hours now)...
The best I can come up with is:

Code: Select all

{fn.match(/\d+x\d+[.]?([^-]\w)\b/).upper().replace(A:'.1',B:'.2',C:'.3',D:'.4',E:'.5',F:'.6',G:'.7',H:'.8',I:'.9').replace('..':'.')}
This is closer but now I get ##x##[Letter] > ##x###.# ie 01x01A > 01x011.1
After some pain and lots more testing [^-] is the "issue" since it says anything but a dash. I could paste the next dozen or so attempts to get around that but either it was the same result as the match pattern above or it was worse at matching what I wanted.

It isn't elegant at all but the only thing I can get to work so far is:

Code: Select all

{n} {episode.special?'00':s.pad(2)}x{es*.pad(2).join('-')}{fn.match(/x[0-9][0-9]\.1|x[0-9][0-9][0-9]\.1|x[0-9][0-9]\.a|x[0-9][0-9][0-9]\.a|x[0-9][0-9]a|x[0-9][0-9][0-9]a/)?'.1':''}{fn.match(/x[0-9][0-9]\.2|x[0-9][0-9][0-9]\.2|x[0-9][0-9]\.b|x[0-9][0-9][0-9]\.b|x[0-9][0-9]b|x[0-9][0-9][0-9]b/)?'.2':''}{fn.match(/x[0-9][0-9]\.3|x[0-9][0-9][0-9]\.3|x[0-9][0-9]\.c|x[0-9][0-9][0-9]\.c|x[0-9][0-9]c|x[0-9][0-9][0-9]c/)?'.3':''}{fn.match(/x[0-9][0-9]\.4|x[0-9][0-9][0-9]\.4|x[0-9][0-9]\.d|x[0-9][0-9][0-9]\.d|x[0-9][0-9]d|x[0-9][0-9][0-9]d/)?'.4':''}{fn.match(/x[0-9][0-9]\.5|x[0-9][0-9][0-9]\.5|x[0-9][0-9]\.e|x[0-9][0-9][0-9]\.e|x[0-9][0-9]e|x[0-9][0-9][0-9]e/)?'.5':''}{fn.match(/x[0-9][0-9]\.6|x[0-9][0-9][0-9]\.6|x[0-9][0-9]\.f|x[0-9][0-9][0-9]\.f|x[0-9][0-9]f|x[0-9][0-9][0-9]f/)?'.6':''}{fn.match(/x[0-9][0-9]\.7|x[0-9][0-9][0-9]\.7|x[0-9][0-9]\.g|x[0-9][0-9][0-9]\.g|x[0-9][0-9]g|x[0-9][0-9][0-9]g/)?'.7':''}{fn.match(/x[0-9][0-9]\.8|x[0-9][0-9][0-9]\.8|x[0-9][0-9]\.h|x[0-9][0-9][0-9]\.h|x[0-9][0-9]h|x[0-9][0-9][0-9]h/)?'.8':''}{fn.match(/x[0-9][0-9]\.9|x[0-9][0-9][0-9]\.9|x[0-9][0-9]\.i|x[0-9][0-9][0-9]\.i|x[0-9][0-9]i|x[0-9][0-9][0-9]i/)?'.9':''}
Last edited by ByteShare on 12 Mar 2019, 21:56, edited 1 time in total.

ByteShare
Posts: 21
Joined: 13 Mar 2018, 15:38

Re: Multipart Episodes & Help with code

Post by ByteShare » 12 Mar 2019, 21:34

I got it!!!

Code: Select all

{'.'+fn.match(/\d{2}x\d{2}\.?(\w)/).upper().replace(A:1,B:2,C:3,D:4,E:5,F:6,G:7,H:8,I:9)}
But I would't have without some starting help. Thank you a bunch.

User avatar
rednoah
The Source
Posts: 16758
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Multipart Episodes & Help with code

Post by rednoah » 13 Mar 2019, 03:44

Haha. What changed? Adding a dot in the begging cost you 3 hours?!?! :shock:

Next time just ask... Takes me 1 second. :roll:
:idea: Please read the FAQ and How to Request Help.

ByteShare
Posts: 21
Joined: 13 Mar 2018, 15:38

Re: Multipart Episodes & Help with code

Post by ByteShare » 13 Mar 2019, 15:22

rednoah wrote:
13 Mar 2019, 03:44
Haha. What changed? Adding a dot in the begging cost you 3 hours?!?! :shock:
There was another issue but it was two parts, one not trying to bother you and more importantly I was trying to learn :)
Next time just ask... Takes me 1 second. :roll:
Will do :) And thank you again for the support.

Post Reply