Page 1 of 1
Renaming movies, {any}method with values + strings troubles
Posted: 04 Nov 2020, 17:05
by IppoKun
I want to write in the filename either {imdb-XXXXX} or {tmdb-XXXXX} (or if none is available, write nothing at all) where the XXXXX is the correspondent id from that website.
Unfortunately using any with a string attached to an value will always value true and return, even if imdbid is null.
Example:
Code: Select all
{any{'{imdb-'+imdbid+'}'}{'{tmdb-'+tmdbid+'}'}}
This will write
if imdbid is not available.
I'm not familiar with this programming language so I'm having problems trying to figure it out
Re: Renaming movies, {any}method with values + strings troubles
Posted: 05 Nov 2020, 03:51
by rednoah

Please include the TheMovieDB link for the specific movie
(i.e. one specific example for testing) you have trouble with.
Generally speaking, the
{plex} format manual has you covered with examples:
rednoah wrote: ↑12 Sep 2016, 10:03
e.g.
Movies/Avatar (2009)/Avatar (2009) {imdb-tt0499549}
e.g.
Movies/Avatar (2009)/Avatar (2009) {tmdb-19995}
e.g. if you want both ids:
Code: Select all
{plex.derive{" {imdb-$imdbid}"}{" {tmdb-$id}"}}
e.g. if you prefer one id but want the others as a default if the preferred one isn't defined:
Code: Select all
{plex.derive{ any{" {imdb-$imdbid}"}{" {tmdb-$id}"} }}

Please read
How to Request Help.
Re: Renaming movies, {any}method with values + strings troubles
Posted: 06 Nov 2020, 11:59
by IppoKun
Input: F:\Test\One.day.Dolores.was.on.her.own.2019.1080p.AMZN.WEB-DL.DDP2.0.H.264-TEPES.mp4
Match: https://www.themoviedb.org/movie/638137 ... quedo-sola
Command Line:
Code: Select all
filebot -script fn:amc --action test --conflict skip -non-strict "F:\Test" --def movieFormat="F:\Test\Library\{plex.derive{ any{\" {imdb-$imdbid}\"}{\" {tmdb-$id}\"} + \" [$fn]\"}.tail}" --def minLengthMS=0
Result:
Code: Select all
[TEST] from [F:\Test\One.day.Dolores.was.on.her.own.2019.1080p.AMZN.WEB-DL.DDP2.0.H.264-TEPES.mp4] to [F:\Test\Library\One day, Dolores was on her own (2019)\One day, Dolores was on her own (2019) {imdb-tt null} [One.day.Dolores.was.on.her.own.2019.1080p.AMZN.WEB-DL.DDP2.0.H.264-TEPES].mp4]
I want to show imdbid by default, unless imdbid is not available (which is this case). If imdbid is not available it should show tmdbid.
Unless I did something wrong, it still is showing {imdb-tt null}, it should show {tmdb-638137}
Re: Renaming movies, {any}method with values + strings troubles
Posted: 06 Nov 2020, 13:12
by rednoah
It works as far as I can tell:
Code: Select all
filebot -rename *.mp4 --db TheMovieDB -non-strict --action TEST --log INFO --format '{plex.derive{ any{" {imdb-$imdbid}"}{" {tmdb-$id}"} }.name}'
[TEST] from [One.day.Dolores.was.on.her.own.2019.1080p.AMZN.WEB-DL.DDP2.0.H.264-TEPES.mp4] to [One day, Dolores was on her own (2019) {tmdb-638137}.mp4]
I happen to be using the latest beta. Perhaps something is broken there in the recent release?
viewtopic.php?t=1609
Re: Renaming movies, {any}method with values + strings troubles
Posted: 06 Nov 2020, 13:27
by IppoKun
I was using the last stable version (Windows non store version), I upgraded to the last beta version and now it is indeed working!
Code: Select all
Auto-detect movie from context [F:\Test\One.day.Dolores.was.on.her.own.2019.1080p.AMZN.WEB-DL.DDP2.0.H.264-TEPES.mp4]
[TEST] from [F:\Test\One.day.Dolores.was.on.her.own.2019.1080p.AMZN.WEB-DL.DDP2.0.H.264-TEPES.mp4] to [F:\Test\Library\One day, Dolores was on her own (2019)\One day, Dolores was on her own (2019) {tmdb-638137} [One.day.Dolores.was.on.her.own.2019.1080p.AMZN.WEB-DL.DDP2.0.H.264-TEPES].mp4]
Re: Renaming movies, {any}method with values + strings troubles
Posted: 30 Jan 2021, 18:11
by RudyBzh
Hi,
I’m having this issue (« tt null ») but it’s on the folder’s name, so I can not use « plex.derive » (as I know).
Here is my format :
Code: Select all
/mnt/NAS/{genres =~ /Animation/ ? 'Animés' : 'Films'}/{plex.name} {'{'+imdbid+'}'}/{plex.name} {'{'+imdbid+'}'}{'['+{source+'-'}+vf+']'+{fn.matchAll(/repack|proper|extended/).join('.').lower().upperInitial()}}{[hdr]}{bitdepth>8?'['+bitdepth+'bit]':''}{[vc]}{[ac+' '+channels]}{[group]}
Is there a sexier way than looking for « null » string in the result to not display it ? Like :
/{plex.name} {imdbid =~ /null/ ?:'{'+imdbid+'}'}/
Of course, if another pieces of my format can be optimized, I take the ideas...
Finaly, I’d like to have « ac+' '+channels » But for a specific language (FR). By the way, I haven’t look in the forum for now if solutions already exists.
Thanks a lot for your advices.
Re: Renaming movies, {any}method with values + strings troubles
Posted: 30 Jan 2021, 20:52
by kim
Code: Select all
{plex.derive{" {${imdbid.minus(null)}}"}.name}
test:
Code: Select all
{def imdbid = null; plex.derive{" {${imdbid.minus(null)}}"}.name}
Code: Select all
{allOf{source}{vf}{fn.matchAll(/repack|proper|extended/).join('.').lower().upperInitial()}.joining('-', ' [', ']')}
sample:
Code: Select all
{allOf{hdr}{bitdepth>8? bitdepth+'bit':''}{vc}{[ac, channels].join(' ')}{group}.joining('][', ' [', ']')}
Multiple audio tracks with different codecs and languages
viewtopic.php?p=51633#p51633
Re: Renaming movies, {any}method with values + strings troubles
Posted: 31 Jan 2021, 11:59
by RudyBzh
Thanks kim for these inputs. Will have a look to the simplifications you propose.
Unfortunately, for the "tt null" issue, it's not working for me :
This code :
Code: Select all
/mnt/NAS/{genres =~ /Animation/ ? 'Animés' : 'Films'}/*/*/*{plex.derive{" {${imdbid.minus(null)}}"}.name}/*/*/*{plex.name} {'{'+imdbid+'}'}/
Gives me this result :
/mnt/NAS/Films/*/*/*Legacy, notre héritage (2021)
{tt }/*/*/*Legacy, notre héritage (2021)
{tt null}/
The black parts are not wanted, of course ^^
Why amc script is not working like usually, simply not displaying "{var}" if "var" is null (here, it concatenates "tt & null" so it's not just "null" ?!
Thanks
Re: Renaming movies, {any}method with values + strings troubles
Posted: 31 Jan 2021, 15:06
by RudyBzh
OK, I've just discovered that imdbid, if not found, is displayed as "tt null" but really contains "tt null" (with 3 blank spaces)...
Re: Renaming movies, {any}method with values + strings troubles
Posted: 31 Jan 2021, 19:24
by kim
@rednoah
This is something rednoah needs to fix
Code: Select all
{imdbid.replaceAll(/tt\s\s\snull/)}
btw: are all the docs updated ?
e.g.
https://www.filebot.net/docs/api/src-ht ... gBean.html
In the meantime use this:
Re: Renaming movies, {any}method with values + strings troubles
Posted: 31 Jan 2021, 20:57
by RudyBzh
Ok, thanks for this.
That’s what I made, but not as efficient as this... have to change

Having a look at the link you provided, honestly, I’m not sure I understood how it’s supposed to work :
Code: Select all
356 @Define("imdbid")
357 public String getImdbId() {
358 if (getMovie().getImdbId() > 0)
359 return String.format(Locale.ROOT, "tt%07d", getMovie().getImdbId());
360 if (getMovie().getTmdbId() > 0)
361 return String.format(Locale.ROOT, "tt%07d", getPrimaryMovieInfo().getImdbId()); // lookup IMDbID for TMDbID
362
363 return null;
364 }
Is my issue due to the 2nd « if » ?
If there’s no imdbid (null) but a tmdbid, you still return the null imdbid with a tt%07d format, so « tt null » with 3 spaces ; 4 chars for « null » + 3 blanks = 7 chars
=> what’s the aim of this ? If it’s the case, I don’t understand ?!?
Notice that it’s the opposite case for tmdb ; it can return null if tmdbid doesn’t exists but imdbid, yes.
Thanks.
Re: Renaming movies, {any}method with values + strings troubles
Posted: 01 Feb 2021, 03:42
by rednoah
The latest revision might work better for this use case, because it'll explicitly
throw undefined if movie.imdbId <= 0 in all cases:
viewtopic.php?t=1609

The code above assumes that String.format %d throws on non-Number values, which unexpectedly isn't the case for null values.
Re: Renaming movies, {any}method with values + strings troubles
Posted: 01 Feb 2021, 06:20
by RudyBzh
Thanks for your response. I assume I have to install the beta version to get this correction ?
If so, is there a way to install it through apt ? (to keep auto upgrades)
I'm currently using this line :
Code: Select all
deb [arch=all] https://get.filebot.net/deb/ universal main
What is the source for beta or dev version ?
Thanks
Re: Renaming movies, {any}method with values + strings troubles
Posted: 01 Feb 2021, 08:57
by RudyBzh
OK, here is what I have now.
Working even without beta throwing error on inexistent imdb.
I guess code could by simplified a bit with beta with something like "any{imdbid}{tmdbid}".
Code: Select all
/mnt/NAS/{genres =~ /Animation/ ? 'Animés' : 'Films'}/{plex.name} {imdbid=~/tt\s+null/? '[tmdb-'+tmdbid+']' : {'['+imdbid+']'}}/
{plex.name}
{allOf
{imdbid=~/tt\s+null/? 'tmdb-'+tmdbid : imdbid}
{allOf
{allOf
{source}
{vf}
.joining('-')
}
{fn.matchAll(/repack|proper|extended/).join('-').lower().upperInitial()}
.joining(' ')
}
{hdr}
{bitdepth>8? bitdepth+'bit' : ''}
{vc}
{[ac, channels].join(' ')}
{group}
.joining('][', '[', ']')
}
Have to look at / tune the audio part to limit the search to one specific wanted language...
Re: Renaming movies, {any}method with values + strings troubles
Posted: 02 Feb 2021, 03:47
by kim
Code: Select all
{genres =~ /Animation/ ? 'Animés' : 'Films'}/
{plex.name}
{imdbid=~/tt\s+null/ ? ' [tmdb-'+tmdbid+']' : {' ['+imdbid+']'}}/
{plex.name}
{allOf
{ imdbid=~/tt\s+null/ ? 'tmdb-'+tmdbid : imdbid }
{ [source, vf].join('-') }
{fn.matchAll(/repack|proper|extended/).join('-').lower().upperInitial() }
{hdr}
{ bitdepth > 8 ? bitdepth+'bit' : '' }
{vc}
{ [ac, channels].join(' ') }
{group}
.joining('][', ' [', ']')
}
Re: Renaming movies, {any}method with values + strings troubles
Posted: 02 Feb 2021, 07:00
by RudyBzh
Thanks Kim for this. But it's not exactly the same. It splits source/vf & repack/proper/extended in different '[xxx]' blocks.
By the while, I take the "{ [source, vf].join('-') }" part.
Re: Renaming movies, {any}method with values + strings troubles
Posted: 02 Feb 2021, 13:09
by RudyBzh
Well, finally
{ [source, vf].join('-') } is not good for me.
I prefer
{allOf {source}{vf}.join('-')}
Because if source is null, I still get {vf}
Re: Renaming movies, {any}method with values + strings troubles
Posted: 03 Feb 2021, 01:14
by kim
@rednoah
What has changed ?
e.g.
This worked before:
Code: Select all
any{ '[' + au['NumberOfDynamicObjects'] + ' Objs]' }{null}
the "fix":
Code: Select all
any{def objects = au['NumberOfDynamicObjects']; objects ? "[$objects Objs]" : ''}{null}
TEST CODE:
FileBot 4.9.2 (r8060):
Code: Select all
{'[' + audio[0]['NumberOfDynamicObjects'] + ' Objs]'}
Binding "NumberOfDynamicObjects": undefined
FileBot 4.9.2 (r8192) + 4.9.3 (r8325):
[null Objs]
Re: Renaming movies, {any}method with values + strings troubles
Posted: 03 Feb 2021, 10:05
by rednoah
Recent revisions allow {audio} (and friends) properties to be null, instead of unwinding on null access. I think we did that for {audio.language} related use cases where the language property may be null for some streams but not others.