Page 1 of 1
Stacked episode renaming
Posted: 30 Dec 2019, 17:06
by Dyolfknip
I was trying to use the stacked episode hack detailed here:
viewtopic.php?t=5240
And it worked great on most of the files I was dealing with. But a few others I kept getting this "Expression yields empty value" error. I'm using 4.8.5.
Code: Select all
filebot -rename -non-strict "paw patrol - all star pups - pups save a sports day.mp4" --format "{episodelist.findAll{ fn =~ it.title }.join(' & ')}" --db thetvdb
Code: Select all
Rename episodes using [TheTVDB]
Auto-detected query: [Paw Patrol]
Fetching episode data for [Paw Patrol]
Expression yields empty value
net.filebot.format.SuppressedThrowables: Expression yields empty value
at net.filebot.format.ExpressionFormat.format(ExpressionFormat.java:163)
at net.filebot.format.ExpressionFormat.format(ExpressionFormat.java:129)
at net.filebot.cli.CmdlineOperations.formatMatches(CmdlineOperations.java:571)
at net.filebot.cli.CmdlineOperations.renameSeries(CmdlineOperations.java:251)
at net.filebot.cli.CmdlineOperations.rename(CmdlineOperations.java:97)
at net.filebot.cli.ArgumentProcessor.runCommand(ArgumentProcessor.java:124)
at net.filebot.cli.ArgumentProcessor.run(ArgumentProcessor.java:33)
at net.filebot.Main.main(Main.java:132)
Error (o_O)
Re: Stacked episode renaming
Posted: 30 Dec 2019, 19:23
by rednoah
1.
If the file name matches no episode title:
Then this will return an empty list:
Code: Select all
episodelist.findAll{ fn =~ it.title }
And then this will return empty string:
Code: Select all
episodelist.findAll{ fn =~ it.title }.join(' & ')
And so you get an error because you're trying to rename a file to nothing.

The linked thread assumes that each file name has an exact corresponding match in the episode titles. This is not necessarily the case in your case.
2.
The first step is to find out:
* What is
fn when it doesn't work?
* What are all possible
title values? Does any of them match?
Then you will need to adjust the condition accordingly, so that you will select the correct episodes for each file. The condition is up to you, and may vary depending on the exact values of file names / episode titles.
Re: Stacked episode renaming
Posted: 30 Dec 2019, 19:55
by kim
the problem is the 'a' in "Pups Save Sports Day" is wrong:
so remove the 'a'
then you can use this:
Code: Select all
{n}{def fileSet = episodelist.findAll{ fn.lower() =~ it.title.lower().replaceAll(/!/) }; ' - S' + s.pad(2) + 'E' + fileSet.episode.min().pad(2) + '-E' + fileSet.episode.max().pad(2) + ' - ' + fileSet.title.join(' & ') }
output:
Paw Patrol - S03E30-E31 - All Star Pups! & Pups Save Sports Day
OR
Code: Select all
{
def epInfo = episodelist.findAll{ fn.lower() =~ it.title.lower().replaceAll(/!/)}.collect{ [ 'name': it.seriesName, 'ep' : 'S' + it.season.pad(2) + 'E' + it.episode.pad(2), title: it.title ] }
epInfo.name[0] + ' - ' + epInfo.ep.join(' & ') + ' - ' + epInfo.title.join(' & ')
}
output:
Paw Patrol - S03E30 & S03E31 - All Star Pups! & Pups Save Sports Day
https://thetvdb.com/series/paw-patrol/episodes/5720764
https://thetvdb.com/series/paw-patrol/episodes/5631547
Re: Stacked episode renaming
Posted: 30 Dec 2019, 21:31
by Dyolfknip
kim wrote: ↑30 Dec 2019, 19:55
the problem is the 'a' in "Pups Save Sports Day" is wrong:
so remove the 'a'
Yeah, I actually tried that one already. It failed for me both ways when stacked, and worked both ways when run by itself. And in any event, I have 15 others with the same problem. Don't think they're all typos.
Re: Stacked episode renaming
Posted: 30 Dec 2019, 21:36
by Dyolfknip
rednoah wrote: ↑30 Dec 2019, 19:23
If the file name matches no episode title:
Problem is, it still says the same thing even if I pare the filename down to just one episode, which it then proceeds to match correctly anyway.
"paw patrol - all star pups!" => "[Expression yields empty value] Paw Patrol - 3x30 - All Star Pups!"
Re: Stacked episode renaming
Posted: 30 Dec 2019, 21:46
by rednoah
Note that formatting is completely unrelated to matching. In this case,
3x30 got matched, but
fn =~ it.title is still false for each item in
episodelist so the format fails. This particular format thoroughly ignores the episode match, and the only thing that has an effect on format is the file part of the match.

Here's a test for
fn =~ it.title and it yields
false:
Code: Select all
{(/all star pups!/ =~ /All Star Pups!/) as boolean}

We'll want to match things regardless of case and punctuation, so we try this, and voilà, it yields true:
Code: Select all
{(/all star pups!/.lower().normalizePunctuation() =~ /All Star Pups!/.lower().normalizePunctuation()) as boolean}

Looking at what we have learnt, this condition should work better:
Code: Select all
fn.lower().normalizePunctuation() =~ it.title.lower().normalizePunctuation()
Re: Stacked episode renaming
Posted: 30 Dec 2019, 21:51
by Dyolfknip
rednoah wrote: ↑30 Dec 2019, 19:23

The linked thread assumes that each file name has an exact corresponding match in the episode titles. This is not necessarily the case in your case.
Ah, I figured it out. "Exact quote" in this case means case-sensitive as well. I had taken the =~ in the original script to mean that it would accept fuzzy matches. Evidently not.
Re: Stacked episode renaming
Posted: 31 Dec 2019, 00:00
by rednoah
I see. Yeah, in this case, if the left-hand side is a String, then
=~ assumes the right-hand side is a regex pattern, so stripping punctuation is probably a good idea just to get rid of potential regex constructs:
http://docs.groovy-lang.org/latest/html ... d_operator
Re: Stacked episode renaming
Posted: 31 Dec 2019, 02:06
by Dyolfknip
Ah, thanks for the docs. Time to learn another scripting language, I guess.
Re: Stacked episode renaming
Posted: 31 Dec 2019, 11:07
by rednoah
Dyolfknip wrote: ↑31 Dec 2019, 02:06
Ah, thanks for the docs. Time to learn another scripting language, I guess.
FileBot will certainly reward you for learning some Groovy fu.
