Deduplicate multi-episode titles

Any questions? Need some help?
Post Reply
dragonandlance
Posts: 15
Joined: 17 Sep 2017, 22:28

Deduplicate multi-episode titles

Post by dragonandlance »

Hello there! I'm sorry I'm not sure what to name this topic, but I really need some help.

I have one MKV that contains two episodes from season 4 of 12 Monkeys; "The Beginning" Part 1 and Part 2.
When I rename it, it becomes "The Beginning Part 1 & The Beginning Part 2", while I'd like it to become just "The Beginning".
The weird thing is that it already works for some episodes; I have another MKV that contains two episodes from season 6 of 30 Rock, "Hey, Baby, What's Wrong" Part 1 and Part 2, which will rename just fine, becoming "Hey, Baby, What's Wrong", instead of the monstrosity above.
I feel like I remember reading something about this on the forum but I couldn't find anything when I searched for it

This is my code, sorry for its ugliness :

Code: Select all

{info.status == 'Ended' ? {['D:', 'F:'].collect{(it+'/'+{n.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /$2/).replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:><|]/, " - ").replaceAll(/[?]/, "").replaceAll(/[\s]+/, " ").replace('*','.').replace('/','-')+' ('+{y}+')'}) as File }.sort{ a, b -> a.exists() <=> b.exists() ?: a.diskSpace <=> b.diskSpace }.last()} : 'E:/'+n.replaceTrailingBrackets().replaceFirst(/^(?i)(The|A|An)\s(.+)/, /$2/).replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:><|]/, " - ").replaceAll(/[?]/, "").replaceAll(/[\s]+/, " ").replace('*','.').replace('/','-')}/{sc == 1 && ('Mini-Series' in genres || info.status == 'Ended') ? '' : "/Season ${s.pad(2)}"}{episode.special ? 'Season 00' : ''}/{episode.special ? 'S00E'+special : {sc == 1 && ('Mini-Series' in genres || info.status == 'Ended') ? "E${e.pad(2)}" : {S00E00}}} - {t.replaceTrailingBrackets().replacePart(', Part $1').replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:><|]/, " - ").replaceAll(/[?]/, "").replaceAll(/[\s]+/, " ").replace('*','.').replace('/','-')}{" [$vf $vc"}{any{$source}{" $source]"}{"]"}} {"[$group]"}{'.'+lang.ISO3}
Thank you in advance!
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming Multi Episodes

Post by rednoah »

The first step is to use a default format such as {plex.name} just to confirm that FileBot has fundamentally identified the files as MultiEpisode object. So that we can focus on correctly formatting this MultiEpisode in a second step.


:idea: {s00e00} and {t} work correctly out-of-the-box for me.

Image


EDIT:

If you select TheTVDB, then it works because The Beginning (1) is a pattern that {t} will take care of implicitly. However, on TheMovieDB it's just The Beginning Part 1 without parenthesis and so FileBot can't tokenize and deduplicate the title for each episode. Please register with TheMovieDB and update the multi-part episode titles to The Beginning (1) or The Beginning (Part 1) format.
:idea: Please read the FAQ and How to Request Help.
dragonandlance
Posts: 15
Joined: 17 Sep 2017, 22:28

Re: Renaming Multi Episode Files

Post by dragonandlance »

Thanks for the quick response.

I actually got the two files mixed up; The Beginning renames fine, while Hey, Baby, What's Wrong doesn't. Sorry about that!

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

Re: Renaming Multi Episode Files

Post by rednoah »

Same concept. The title that has been entered into your selected database doesn't follow that standard pattern, and so FileBot can't detect that these two titles are supposed to be the same.



EDIT:

If it's just a one-off, then I'd just use Double-Click ➔ Edit Name to fix it manually before renaming case-by-case as needed:
Image
:idea: Please read the FAQ and How to Request Help.
dragonandlance
Posts: 15
Joined: 17 Sep 2017, 22:28

Re: Deduplicate multi-episode titles

Post by dragonandlance »

Thats what I was afraid of, but thank you so much for the help!
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Deduplicate multi-episode titles

Post by kim »

You can do this:

Code: Select all

{def onePart = t.split(' & ')*.replaceAll(/\sPart\s\d/).unique().join(' & ')
plex.name.replace(t, onePart)
}
or

Code: Select all

{def onePart = t.split(' & ')*.replacePart('').unique().join(' & ')
plex.name.replace(t, onePart)}
sample:

Code: Select all

12 Monkeys - S04E10-E11 - The Beginning
or

Code: Select all

{def onePart = t.split(' & ')*.replaceAll(/\sPart\s(\d)/, ' ($1)').unique().join(' & ')
plex.name.replace(t, onePart)
}
sample:

Code: Select all

12 Monkeys - S04E10-E11 - The Beginning (1) & The Beginning (2)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Deduplicate multi-episode titles

Post by rednoah »

:idea: Please read the FAQ and How to Request Help.
Post Reply