[Help] Parts not working with TheTVDB

All about user-defined episode / movie format expressions
Post Reply
Crankrune
Posts: 21
Joined: 20 Jul 2016, 11:35

[Help] Parts not working with TheTVDB

Post by Crankrune » 19 Aug 2016, 22:42

In my TV format I use this for parts. There's a lot more to it, but that's what I have regarding parts.

Code: Select all

{t.replacePart(' [Part $1]')
When I match to TheTVDB, which I usually use, it does not append the Part #. Even if I just use {t}. However when I match to TVmaze, the parts work just fine. I also tried a couple different ways of matching/replacing the "(1)", but they didn't work. Not sure if this is a bug or something incorrect in my format.

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

Re: [Help] Parts not working with TheTVDB

Post by rednoah » 20 Aug 2016, 01:12

Depending on the value of {t} it'll always work or not work. If the title ends with (1) (2) etc it'll work.

e.g.

Code: Select all

{'Test (1)'.replacePart(' [Part $1]')}
:idea: Please read the FAQ and How to Request Help.

Crankrune
Posts: 21
Joined: 20 Jul 2016, 11:35

Re: [Help] Parts not working with TheTVDB

Post by Crankrune » 20 Aug 2016, 01:22

I just used that test, and it worked. {t} isn't returning the (1) (2). However {episode} is and replacePart isn't working with that. Any ideas on how I can this part thing to work? I can't figure out how to use any .match or .replace to work with {episode}.

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

Re: [Help] Parts not working with TheTVDB

Post by rednoah » 20 Aug 2016, 01:53

1.
Crankrune wrote:{t} isn't returning the (1) (2)
Time to tell us what TV Show / Episodes you're renaming.


2.
{episode} is an Episode object, not a String object, so you need to do episode.toString() if you want to use String methods.
:idea: Please read the FAQ and How to Request Help.

Crankrune
Posts: 21
Joined: 20 Jul 2016, 11:35

Re: [Help] Parts not working with TheTVDB

Post by Crankrune » 20 Aug 2016, 02:44

1.
DC's Legend of Tomorrow, Season 1 Episode 1
Star Trek - Enterprise, Season 4 Episodes 1&2 (separate files)

2.
Thanks for that. I had this to use as a workaround. Just not sure how to have a variable in the part number.

Code: Select all

{episode.toString().match(/([0-9])/); ' [Part 1]'}

Crankrune
Posts: 21
Joined: 20 Jul 2016, 11:35

Re: [Help] Parts not working with TheTVDB

Post by Crankrune » 20 Aug 2016, 06:08

Update: Parts still not working with TheTVDB, whipped this up as a workaround for now.

Code: Select all

{' [Part '+episode.toString().match(/\([0-9]+\)$/)[1]+']'}

drauku
Posts: 8
Joined: 19 Aug 2016, 07:17

Re: [Help] Parts not working with TheTVDB

Post by drauku » 12 Sep 2016, 17:35

I am also having this issue. I've used a couple different code formats (below), but none will return the part number for the below episodes.

@Crankrune I used your work-around for a few shows, and that fixed some but not all episodes. Not sure what is going on here.

Code: Select all

{' ('+episode.toString().match(/\([0-9]+\)$/)[1]+')'}

Code: Select all

{" Part $pi"}

Code: Select all

{t}

Code: Select all

{pi}
Original episode names:
Image

What they turn into with the above code snippets:
Image

I am using a modified version of Ilthiel's renaming code, forked from DevXen's Enhanced naming scheme for the rest.

drauku
Posts: 8
Joined: 19 Aug 2016, 07:17

Re: [Help] Parts not working with TheTVDB

Post by drauku » 12 Sep 2016, 20:42

I noticed that this IS working for some cartoon episodes:

Code: Select all

{' ('+episode.toString().match(/\([0-9]+\)$/)[1]+')'}
Image
turns into:
Image

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

Re: [Help] Parts not working with TheTVDB

Post by rednoah » 13 Sep 2016, 03:13

The latest revision should work as expected:

Code: Select all

{t.replacePart(' [$1]')}
:idea: Please read the FAQ and How to Request Help.

drauku
Posts: 8
Joined: 19 Aug 2016, 07:17

Re: [Help] Parts not working with TheTVDB

Post by drauku » 16 Sep 2016, 01:00

@rednoah thank you much for that updated code snippet! It worked quite well.

I noticed one instance where it doesn't correctly leave out the 'Part' or produce the right name (notice the duplication)... all other instances I've tried worked fine though, including the episode name.

Code: Select all

 Star Trek - The Next Generation [s01e01-e02] Encounter At Farpoint, Part 1 & Encounter At Farpoint, Part 2 Encounter at Farpoint, Part 1 & Encounter at Farpoint [2] - [90 Min] [1987-09-28] [240p MP3 2ch]

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

Re: [Help] Parts not working with TheTVDB

Post by rednoah » 16 Sep 2016, 03:39

Format:

Code: Select all

{n} - {s00e00} - {t}
Yields:

Code: Select all

Star Trek: The Next Generation - S01E01-E02 - Encounter at Farpoint
What is your format?
:idea: Please read the FAQ and How to Request Help.

drauku
Posts: 8
Joined: 19 Aug 2016, 07:17

Re: [Help] Parts not working with TheTVDB

Post by drauku » 18 Sep 2016, 17:18

rednoah wrote:What is your format?
I'm using a modified version of DrevXen's show format viewtopic.php?f=5&t=2#p12156

Code: Select all

{norm = {it.upperInitial().lowerTrail().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ").replaceAll(/\b[IiVvXx]+\b/, { it.upper()}).replaceAll(/\b[0-9](?i:th|nd|rd)\b/, {it.lower()})}; norm(n).replaceFirst(/^(?i)(The|A|An)\s(.+)/, /$2, $1/).replaceTrailingBrackets()} {' '+n.match(/\([A-Z]+\)$/)} {if (norm(n) != norm (primaryTitle)) ' ('+norm(primaryTitle)+')'} {fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""} {if (y) {' ['+y +']'}} {' '+any{"[$certification]"}{"["+$imdb.certification+"]" }.replaceAll('N A','').replaceAll(/^ \d+$/, 'PG-$0')} {" [$rating" + "★]"} [{csv('C:/FileBot/Settings/Shows/TVNetwork.csv').get(info.network) ?: info.network }]/ {[episodelist.findAll{ it.season == s }.airdate.year.min()]} {episode.special ? ' Season '+s.pad(2)+'/[Specials]' : ' Season '+s.pad(2)}/ {csv('C:/FileBot/Settings/Shows/TVFileShowNames.csv').get(n) ?: norm(n).replaceTrailingBrackets()} {' '+n.match(/\([A-Z]+\)$/)} {' '+n.match(/\([0-9]+\)$/)} {[episode.special ? 's00e'+special.pad(2)+'' : ''+s00e00.lower()+'']} {norm(t.replaceAll("\\s*[(]([^)]*)[)]\$", { group, match -> ' (Part '+match.pad(2)+')' }))} {fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""} {' (' + fn.matchAll(/extended|uncensored|remastered|unrated|uncut|directors.cut|special.edition|unsold.pilot|unaired.pilot| unaired.episode/)*.upperInitial()*.lowerTrail().sort().join(', ').replaceAll(/ [._]/, " ") + ')'} {t.replacePart(' [$1]')} - {" [$minutes Min]"} {' '+[airdate.format("yyyy-MM-dd")]} {" [$source]"} {" [$vf $ac $af]"}
I just tested it with Crusade, and every episode has a duplicated title. Perhaps I should start a different thread, as episode Parts are working now.

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

Re: [Help] Parts not working with TheTVDB

Post by rednoah » 18 Sep 2016, 17:44

Your format is at fault then. I recommend using simple format that you can understand and debug if things don't work as expected. ;)
:idea: Please read the FAQ and How to Request Help.

Steve
Posts: 2
Joined: 10 Jan 2017, 17:20

Re: [Help] Parts not working with TheTVDB

Post by Steve » 10 Jan 2017, 17:35

Hi, going back to the original problem on this thread I'm not sure it has been fixed. Or indeed if it has just come up again.

I have tested with Filebot 4.7.5 and 4.7.7 and get different results, but not the correct ones.

With 4.7.5 it seems to ignore replacePart completely
With 4.7.7 it adds the string expression ", Part ", but not the part number. ", Part " is only added to episodes that have a part number, so it would appear it can pick up that there is a part number, but not what the part number is.

Here is the def string I use for TV episodes:

seriesFormat=/Media/TV Shows/{n}/{episode.special ? 'Specials' : 'Season '+s.pad(2)}/{n} {s00e00} {t.replaceAll(/[´''?]/, /'/).replaceAll(/[!?.]+$/).replacePart(', Part $1')}

I believe this stopped working last year about September time when I was still running on Windows, but I have not fully tested before today and I am now running on Linux.

Coincidentally I also have the problem if I use the {plex} naming option. Although I am not sure if this is by design.

Thanks in advance for any help you can offer.

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

Re: [Help] Parts not working with TheTVDB

Post by rednoah » 10 Jan 2017, 17:39

Thanks for the post! Before a real human comes by, please make sure your report has all the following points checked:
  • What are you trying to do achieve? What's not working? What have you tried so far?
  • Include screenshots, logs or filenames (i.e. demonstrate the issue)
  • Include basic information (i.e. sysinfo output)
:idea: Please read How to Request Help and Fix Problems, Report Bugs, Get Features
:idea: Please read the FAQ and How to Request Help.

drauku
Posts: 8
Joined: 19 Aug 2016, 07:17

Re: [Help] Parts not working with TheTVDB

Post by drauku » 11 Jan 2017, 02:06

Steve wrote:Hi, going back to the original problem on this thread I'm not sure it has been fixed. Or indeed if it has just come up again.
Thanks for replying in this thread! You refreshed this issue in my mind, and I worked on it again today... finally solving my problem!

FYI, I tested your exact naming expression and it worked for me using the episodes listed below.

Code: Select all

{n}/{episode.special ? 'Specials' : 'Season '+s.pad(2)}/{n} {s00e00} {t.replaceAll(/[´''?]/, /'/).replaceAll(/[!?.]+$/).replacePart(', Part $1')}

Code: Select all

.../X-Men: The Animated Series S0E01 Out of the Past, Part 1
.../X-Men: The Animated Series S0E02 Out of the Past, Part 2
You will have to tell us exactly which episodes you are using, which Order you have chosen, and which method you are using to call the FileBot renaming function (command line, gui, script) for us to reproduce your erroneous results.

@RedNoah has an example naming scheme with episode part that I used to produce the below results, showing that part does work as expected:

Code: Select all

{n.replaceTrailingBrackets()} - {s+'x'}{e.pad(2)} - {t.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").replacePart(' (Part $1)')}

Code: Select all

.../X-Men: The Animated Series - 3x01 - Out of the Past (Part 1)
.../X-Men: The Animated Series - 3x02 - Out of the Past (Part 2)
However, I also created a basic naming format using only the {plex} tag, and the episodes were renamed without the episode part segment of the filename, which means to me that the plex tag might have an issue. YMMV

I have modified my format so extensively that the original posts about it in this thread no longer apply. Here is my most recent iteration that actually works as of this afternoon:

Code: Select all

{norm = {it.replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ").replaceAll(/\b[IiVvXx]+\b/, { it.upper()}).replaceAll(/\b[0-9](?i:th|nd|rd)\b/, {it.lower()})}; csv('C:/FileBot/Settings/Shows/ShowFolderNames.csv').get(n) ?: norm(n).replaceFirst(/^(?i)(The|A|An)\s(.+)/, /$2, $1/)}
{' '+n.match(/\([A-Z]+\)$/)}
{if ((n) != (primaryTitle)) ' ('+norm(primaryTitle)+')'}
{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""}
{if (y) {' ['+y +']'}}
{"[$rating"+"★]"}
{any{"[$certification]"}{"["+$omdb.certification+"]" }.replaceAll('N A','NR').replaceAll(/^ \d+$/, 'PG-$0')}
{"/"}
{[episodelist.findAll{it.season == s}.airdate.year.min()]}
{episode.special ? ' Season '+s.pad(2)+'/[Specials]' : ' Season '+s.pad(2)}
{"/"}
{csv('C:/FileBot/Settings/Shows/ShowFileNames.csv').get(n) ?: norm(n)}
{' '+n.match(/\([A-Z]+\)$/)}
{' '+n.match(/\([0-9]+\)$/)}
{" "}
{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D ':""}
{[episode.special ? 's00e'+special.pad(2)+'' : ''+s00e00.lower()+'']}
{" "}
{norm(t.replacePart(' (Part $1)'))}
{" - "}
{' [' + fn.matchAll(/extended|uncensored|remastered|unrated|uncut|directors.cut|special.edition|unsold.pilot|unaired.pilot|unaired.episode/)*.upperInitial()*.lowerTrail().sort().join(', ').replaceAll(/ [._]/, " ") + ']'}
{"[$minutes-min]"}
{"[$vf-$vc]"}
{"[$af-$ac]"}
{any{".$cf"}{".$ext"}}
This naming scheme produces a long but informative folder path and file name:

Code: Select all

...\Last Man on Earth, The [2015][7.4★][TV-14]\The Last Man on Earth [s01e01-e02] Alive in Tucson & The Elephant in the Room - [43-min][480p-x264][2ch-AAC].mp4
...\X-Men - The Animated Series [1992][9.0★][TV-Y7]\X-Men- TAS [s03e01] Out of the Past (Part 1) - [20-min][240p-DivX][2ch-MP3].avi
...\X-Men - The Animated Series [1992][9.0★][TV-Y7]\X-Men- TAS [s03e02] Out of the Past (Part 2) - [20-min][240p-DivX][2ch-MP3].avi
...\X-Men - The Animated Series [1992][9.0★][TV-Y7]\X-Men- TAS [s03e03] Phoenix Saga (Part 1) - Sacrifice - [20-min][240p-DivX][2ch-MP3].avi
...\X-Men - The Animated Series [1992][9.0★][TV-Y7]\X-Men- TAS [s03e04] Phoenix Saga (Part 2) - The Dark Shroud - [20-min][240p-DivX][2ch-MP3].avi
My original format included a function called '.replaceTrailingBrackets()' inside the 'norm' function, which was making the 'part' field disappear in the filename. I'm assuming it would delete anything inside a '()' at the end of the field.

Hopefully this discovery will help you, but like I said before... your naming scheme worked for me.

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

Re: [Help] Parts not working with TheTVDB

Post by rednoah » 11 Jan 2017, 05:27

@Steve Please learn how to use bash.

Compare and Contrast:

Code: Select all

echo "Hello $1"

Code: Select all

echo 'Hello $1'

Code: Select all

echo "Hello \$1"
:idea: Please read the FAQ and How to Request Help.

Steve
Posts: 2
Joined: 10 Jan 2017, 17:20

Re: [Help] Parts not working with TheTVDB

Post by Steve » 11 Jan 2017, 10:47

Thanks for the tips. This is now working for me:

Code: Select all

--def "seriesFormat=/share/Media/TV Shows/{n}/{episode.special ? 'Specials' : 'Season '+s.pad(2)}/{n} {s00e00} {t.replaceAll(/[´''?]/, /'/).replaceAll(/[!?.]+$/).replacePart(', Part \$1')}"
Just needed that extra backslash I guess. This will obviously not fix the issue with the {plex} option though if people are using that.

Result with my new series def

Code: Select all

[MOVE] Rename [/share/torename/X-Men The Animated Series S03E01 Out of the Past (Part 1).m4v] to [/share/Media/TV Shows/X-Men The Animated Series/Season 03/X-Men The Animated Series S03E01 Out of the Past, Part 1.m4v]
[MOVE] Rename [/share/torename/X-Men The Animated Series S03E02 Out of the Past (Part 2).m4v] to [/share/Media/TV Shows/X-Men The Animated Series/Season 03/X-Men The Animated Series S03E02 Out of the Past, Part 2.m4v]
Result with /share/Media/{plex}

Code: Select all

[MOVE] Rename [/share/torename/X-Men The Animated Series S03E01 Out of the Past (Part 1).m4v] to [/share/Media/TV Shows/X-Men - The Animated Series/Season 03/X-Men - The Animated Series - S03E01 - Out of the Past.m4v]
[MOVE] Rename [/share/torename/X-Men The Animated Series S03E02 Out of the Past (Part 2).m4v] to [/share/Media/TV Shows/X-Men - The Animated Series/Season 03/X-Men - The Animated Series - S03E02 - Out of the Past.m4v]
Interestingly {plex} also adds a hyphen in the middle of the series name that is not picked up normally too.

Once again, thanks for your help.

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

Re: [Help] Parts not working with TheTVDB

Post by rednoah » 11 Jan 2017, 11:23

Raw Data:

Code: Select all

filebot -list --q "X-Men The Animated Series" --filter "s == 3 && e <= 2"

Code: Select all

X-Men: The Animated Series - 3x01 - Out of the Past (Part 1)
X-Men: The Animated Series - 3x02 - Out of the Past (Part 2)
The {plex} format removes trailing parenthesis in the episode title. It'll also replace illegal characters (e.g. replace colon with dash). This is intended behavior.
:idea: Please read the FAQ and How to Request Help.

kim
Power User
Posts: 756
Joined: 15 May 2014, 16:17

Re: [Help] Parts not working with TheTVDB

Post by kim » 05 Feb 2018, 06:20

I found problem with "replacePart"
on e.g. https://www.thetvdb.com/?tab=episode&se ... 7067&lid=7

Episode Name:
Operations Security (OPSEC)

Code: Select all

{t.replacePart(/(Part.$1)/)}
problem is output =
Operations Security(Part.OPSEC)
why do FB think "(OPSEC)" is a "Part" thing ?

can you replace the regex code with something like this?:

Code: Select all

[(]([\d])[)]$|[(](\w+\s?[\d])[)]$|[(](part+\s\w+)[)]$
so only part if e.g. (1), (something 1) or (part one)

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

Re: [Help] Parts not working with TheTVDB

Post by rednoah » 05 Feb 2018, 06:24

I won't change behaviour unless at least a couple of people find this to be an issue. There's probably a couple of users that prefer the current behaviour, where Part A and Part B are as valid as Part 1 and Part 2.

If you want to only match Part.[0-9] then you can use your own Groovy code regular expression of course and achieve exactly what you want.
:idea: Please read the FAQ and How to Request Help.

kim
Power User
Posts: 756
Joined: 15 May 2014, 16:17

Re: [Help] Parts not working with TheTVDB

Post by kim » 05 Feb 2018, 06:28

well my code will match "(Part B)" also

Code: Select all

[(]([\d])[)]$|[(](\w+\s?[\d])[)]$|[(](part+\s\w+)[)]$
I see no downside to the fix/change

but the current code has this false positive... also if
Operations Security (sdfljhdsflhfdsljhfljsdhvsdlfhesboihsdflishflshfsdlfjhvslifsehbf)

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

Re: [Help] Parts not working with TheTVDB

Post by rednoah » 05 Feb 2018, 06:48

Presumably, (A) and (B) are quite common to identify Part 1 and Part 2 and so on. As a compromise, I'll change \w+ to \w{1,3}.
:idea: Please read the FAQ and How to Request Help.

kim
Power User
Posts: 756
Joined: 15 May 2014, 16:17

Re: [Help] Parts not working with TheTVDB

Post by kim » 05 Feb 2018, 15:11

what about e.g. Operations Security (part 1) then ?

Code: Select all

[(](\d{1,3})[)]$|[(](\D{1,3}\s?\d{1,3})[)]$|[(](part+\s\w+)[)]$

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

Re: [Help] Parts not working with TheTVDB

Post by rednoah » 05 Feb 2018, 17:51

The "Part XYZ" is another patterns and remains unchanged.
:idea: Please read the FAQ and How to Request Help.

Post Reply