Renaming movies, {any}method with values + strings troubles

Any questions? Need some help?
Post Reply
IppoKun
Posts: 5
Joined: 04 Nov 2020, 16:57

Renaming movies, {any}method with values + strings troubles

Post 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

Code: Select all

imdb-tt null
if imdbid is not available.

I'm not familiar with this programming language so I'm having problems trying to figure it out
User avatar
rednoah
The Source
Posts: 19435
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming movies, {any}method with values + strings troubles

Post 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}

Code: Select all

{plex.derive{" {imdb-$imdbid}"}}
e.g. Movies/Avatar (2009)/Avatar (2009) {tmdb-19995}

Code: Select all

{plex.derive{" {tmdb-$id}"}}

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}"} }}

:idea: Please read How to Request Help.
:idea: Please read the FAQ and How to Request Help.
IppoKun
Posts: 5
Joined: 04 Nov 2020, 16:57

Re: Renaming movies, {any}method with values + strings troubles

Post 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}
User avatar
rednoah
The Source
Posts: 19435
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming movies, {any}method with values + strings troubles

Post 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
:idea: Please read the FAQ and How to Request Help.
IppoKun
Posts: 5
Joined: 04 Nov 2020, 16:57

Re: Renaming movies, {any}method with values + strings troubles

Post 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]
RudyBzh
Posts: 22
Joined: 31 Mar 2013, 14:05

Re: Renaming movies, {any}method with values + strings troubles

Post 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.
kim
Power User
Posts: 1097
Joined: 15 May 2014, 16:17

Re: Renaming movies, {any}method with values + strings troubles

Post 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

[WEBRip-1080p-Extended]

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
RudyBzh
Posts: 22
Joined: 31 Mar 2013, 14:05

Re: Renaming movies, {any}method with values + strings troubles

Post 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
RudyBzh
Posts: 22
Joined: 31 Mar 2013, 14:05

Re: Renaming movies, {any}method with values + strings troubles

Post 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)...
kim
Power User
Posts: 1097
Joined: 15 May 2014, 16:17

Re: Renaming movies, {any}method with values + strings troubles

Post by kim »

@rednoah
This is something rednoah needs to fix

Code: Select all

tt   null

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:

Code: Select all

{imdbid.replaceAll(/tt\s+null/)}
RudyBzh
Posts: 22
Joined: 31 Mar 2013, 14:05

Re: Renaming movies, {any}method with values + strings troubles

Post 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.
User avatar
rednoah
The Source
Posts: 19435
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming movies, {any}method with values + strings troubles

Post 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.
:idea: Please read the FAQ and How to Request Help.
RudyBzh
Posts: 22
Joined: 31 Mar 2013, 14:05

Re: Renaming movies, {any}method with values + strings troubles

Post 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
RudyBzh
Posts: 22
Joined: 31 Mar 2013, 14:05

Re: Renaming movies, {any}method with values + strings troubles

Post 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...
kim
Power User
Posts: 1097
Joined: 15 May 2014, 16:17

Re: Renaming movies, {any}method with values + strings troubles

Post 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('][', ' [', ']')
}
RudyBzh
Posts: 22
Joined: 31 Mar 2013, 14:05

Re: Renaming movies, {any}method with values + strings troubles

Post 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.
RudyBzh
Posts: 22
Joined: 31 Mar 2013, 14:05

Re: Renaming movies, {any}method with values + strings troubles

Post 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}
kim
Power User
Posts: 1097
Joined: 15 May 2014, 16:17

Re: Renaming movies, {any}method with values + strings troubles

Post by kim »

@rednoah

What has changed ?

e.g.

Code: Select all

{'{'+imdbid+'}'}
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]
User avatar
rednoah
The Source
Posts: 19435
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming movies, {any}method with values + strings troubles

Post 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.
:idea: Please read the FAQ and How to Request Help.
Post Reply