Renaming Children's Shows with multiple episode names per airing

All about user-defined episode / movie / file name format expressions
Post Reply
daphatty
Posts: 6
Joined: 20 Jul 2020, 06:15

Renaming Children's Shows with multiple episode names per airing

Post by daphatty »

I'm in the process of evaluating Filebot for use in an elaborate script I'm writing that converts DVR recordings from Over the Air broadcasts into MP4 format and then renames the shows based on results from online metadata DBs like TVDB.

In this specific use case, I am running into a bit of challenge with PBS children's shows like Daniel Tiger's Neighborhood, where each 30 minute airing actually contains two unique episodes, each with their own title. The files I am attempting to rename and tag have the following structure.

<show-title>.<original-air-date>.<episode1-name;episode2-name>.mp4

e.g. Daniel Tigers Neighborhood.2019-01-08T00:00:00Z.Daniels Obstacle Course; Daniel Plays in a Gentle Way.mp4

The file name structure of the source file is derived from metadata provided by the DVR program and only includes information that is guaranteed to be the same across all metadata sources. Season and Episode numbers for Children's shows are rarely, if ever, the same between OTA and Online metadata sources and therefore, the Season and Episode numbers are omitted from the source file name.

Following the guidance this thread, the following command

Code: Select all

filebot -rename "Daniel Tigers Neighborhood.2019-01-08T00:00:00Z.Daniels Obstacle Course; Daniel Plays in a Gentle Way.mp4" --db TheTVDB --mapper "episode.derive(0)" --action TEST -non-strict
provides the following result.

Code: Select all

Reverse Map [Daniel Tiger's Neighborhood - 00] to [Daniel Tiger's Neighborhood - 4x12 - Daniel Plays in a Gentle Way]
[TEST] from [/home/<username>/OTA2MP4/Complete/Daniel Tigers Neighborhood.2019-01-08T00:00:00Z.Daniels Obstacle Course; Daniel Plays in a Gentle Way.mp4] to [/home/<username>/OTA2MP4/Complete/Daniel Tiger's Neighborhood - 4x12 - Daniel Plays in a Gentle Way.mp4]
As you can see, the rename gets close but only tags one of the two episodes. I suspect I need to provide additional details in the rename command itself but so far, I've been unable to figure out what that might be. Ultimately, I'd like the resulting file name to be:

<show-title> - <SxxExx-xx> - <episode1-name, episode2-name>.mp4

e.g. Daniel Tiger's Neighborhood - S04E11-12 - Daniels Obstacle Course, Daniel Plays in a Gentle Way.mp4

Thanks in advance for any feedback you provide.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming Children's Shows with multiple episode names per airing

Post by rednoah »

MultiEpisode support is a bit special in that it only works for relatively well-named files, e.g. S01E01-E02.

In this case, we're matching by airdate only, and there's no special handling for coalescing multiple possible matches based on a single common airdate into a single deterministic MultiEpisode match.

I'll see what I can come up with. It's probably possible to make it kinda work, but it might not be pretty. I'll play with it when I have time.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Renaming Children's Shows with multiple episode names per airing

Post by kim »

already done this ;)

Code: Select all

{n}{def fileSet = episodelist.findAll{ airdate == it.airdate }; ' - S' + s.pad(2) + 'E' + fileSet.episode.min().pad(2) + '-E' + fileSet.episode.max().pad(2) + ' - ' + fileSet.title.join(' & ') }
detecting multi episodes?!?!

output
Daniel Tiger's Neighborhood - S04E11-E12 - Daniel's Obstacle Course & Daniel Plays in a Gentle Way
bonus info:
Easier way to prep double episode file for Filebot?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming Children's Shows with multiple episode names per airing

Post by rednoah »

Here's what I managed to come up, though it probably won't be very useful unless you have a greater script that can make different filebot call for different files:

Code: Select all

filebot -list -rename \
	--db TheTVDB \
	--mapper "episodelist.findAll{ airdate == it.airdate } as net.filebot.web.MultiEpisode" \
	--q "Daniel Tiger's Neighborhood" \
	--filter "airdate =~ /2019.01.08/" \
	"Daniel Tigers Neighborhood.2019-01-08T00.00.00Z.Daniels Obstacle Course; Daniel Plays in a Gentle Way.mp4" \
	--action TEST --log INFO

Code: Select all

[TEST] from [Daniel Tigers Neighborhood.2019-01-08T00.00.00Z.Daniels Obstacle Course; Daniel Plays in a Gentle Way.mp4] to [Daniel Tiger's Neighborhood - 4x11 & 4x12 - Daniel's Obstacle Course & Daniel Plays in a Gentle Way.mp4]

:!: Notably, if --mapper is used in combination with with -rename mode automatic matching (as opposed to -list -rename mode sequential matching) then the --mapper result is used for matching only, but not as source of truth for naming, thus --mapper might be somewhat in the context of -rename (as opposed to -list -rename) calls for this particular use case.
:idea: Please read the FAQ and How to Request Help.
daphatty
Posts: 6
Joined: 20 Jul 2020, 06:15

Re: Renaming Children's Shows with multiple episode names per airing

Post by daphatty »

kim wrote: 20 Jul 2020, 11:21 already done this ;)

Code: Select all

{n}{def fileSet = episodelist.findAll{ airdate == it.airdate }; ' - S' + s.pad(2) + 'E' + fileSet.episode.min().pad(2) + '-E' + fileSet.episode.max().pad(2) + ' - ' + fileSet.title.join(' & ') }
detecting multi episodes?!?!

output
Daniel Tiger's Neighborhood - S04E11-E12 - Daniel's Obstacle Course & Daniel Plays in a Gentle Way
bonus info:
Easier way to prep double episode file for Filebot?
@kim - Thank you for the guidance and supporting threads outlining your solution. It took me a while to figure out the proper syntax (I'm still very new to this) but everything came together when I figured out your string is meant to be prefaced with --format.

Code: Select all

--format {n}{def fileSet = episodelist.findAll{ airdate == it.airdate }; ' - S' + s.pad(2) + 'E' + fileSet.episode.min().pad(2) + '-E' + fileSet.episode.max().pad(2) + ' - ' + fileSet.title.join(' & ') }
Note: For anyone who comes across this post looking for a solution to a similar problem, it should be noted that this will only work if the Airdates match.
rednoah wrote: 20 Jul 2020, 08:26 MultiEpisode support is a bit special in that it only works for relatively well-named files, e.g. S01E01-E02.

In this case, we're matching by airdate only, and there's no special handling for coalescing multiple possible matches based on a single common airdate into a single deterministic MultiEpisode match.

I'll see what I can come up with. It's probably possible to make it kinda work, but it might not be pretty. I'll play with it when I have time.
@rednoah - Thank you for taking the time to respond and for contemplating a potential solution to this challenge. As noted above, Kim's format suggestion works well as it leverages a successful match to pull and leverage the missing data. That said, successful renames only work if the Airdates match.

Perhaps it would be possible to expand the --mapper request such that several match cases could be provided and processed in order of priority? For example, if the Airdate match fails, compare Show Title and Episode Name (or multiple names in my case) as a backup criteria. This could be beneficial to a more successful end result in some edge cases.

Anyway, just some food for thought. Thank you both for the helpful responses. I will now toil away to learn more about this very useful tool.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming Children's Shows with multiple episode names per airing

Post by rednoah »

daphatty wrote: 20 Jul 2020, 15:12 Perhaps it would be possible to expand the --mapper request such that several match cases could be provided and processed in order of priority? For example, if the Airdate match fails, compare Show Title and Episode Name (or multiple names in my case) as a backup criteria. This could be beneficial to a more successful end result in some edge cases.
FileBot already does that. Any identifying information that you have in the file name (e.g. numbers, dates, titles) plus --mapper can yield multiple mappings, but the end result will always be 1 episode match per 1 file. The tricky part is sometimes matching N episodes per 1 file, which FileBot only solves partially for common use cases.

:idea: Notably, 2019-01-08T00:00:00Z just so happens to not work as date pattern because the T breaks things. FileBot happens to expect it's 2019-01-08 date patterns to not be surrounded by alphanumeric characters. But even if it just said 2019-01-08 in the file name, you'd still end up with just 1 episode match.


TL;DR There's probably no good solution, other then letting FileBot match one part of the multi-episode, and then having special purpose custom code fix names up via the format. Note that FileBot won't be aware of things in this case, and xattr won't reflect the multi-episode nature of the file, so xattr based tools might not pick things up as expected.
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming Children's Shows with multiple episode names per airing

Post by rednoah »

FileBot r7743 add improves support for reverse mapping, though it's certainly on the advanced side and will probably stay undocumented:

Code: Select all

filebot -rename \
	. \
	-non-strict \
	--db TheTVDB \
	--mapper "episode.map(episodelist.findAll{ airdate == it.airdate }).reverse()" \
	--action TEST \
	--log INFO

Code: Select all

[TEST] from [Daniel Tigers Neighborhood.2019-01-08T00.00.00Z.Daniels Obstacle Course; Daniel Plays in a Gentle Way.mp4] to [Daniel Tiger's Neighborhood - 4x11 & 4x12 - Daniel's Obstacle Course & Daniel Plays in a Gentle Way.mp4]
:idea: Please read the FAQ and How to Request Help.
daphatty
Posts: 6
Joined: 20 Jul 2020, 06:15

Re: Renaming Children's Shows with multiple episode names per airing

Post by daphatty »

rednoah wrote: 20 Jul 2020, 16:52
daphatty wrote: 20 Jul 2020, 15:12 Perhaps it would be possible to expand the --mapper request such that several match cases could be provided and processed in order of priority? For example, if the Airdate match fails, compare Show Title and Episode Name (or multiple names in my case) as a backup criteria. This could be beneficial to a more successful end result in some edge cases.
:idea: Notably, 2019-01-08T00:00:00Z just so happens to not work as date pattern because the T breaks things. FileBot happens to expect it's 2019-01-08 date patterns to not be surrounded by alphanumeric characters. But even if it just said 2019-01-08 in the file name, you'd still end up with just 1 episode match.
Thank you for this insight. Now I can tweak my script to better provide Filebot with more accurate data. Since I am already renaming my source files (based on OTA metadata), I can simply truncate the Airdate value so it matches exactly what Filebot expects.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming Children's Shows with multiple episode names per airing

Post by rednoah »

FileBot r7745 adds support for 2019-01-08T00:00:00Z style date patterns.
:idea: Please read the FAQ and How to Request Help.
Post Reply