What is {n}?

All about user-defined episode / movie / file name format expressions
Post Reply
UKenGB
Posts: 49
Joined: 04 Jan 2017, 09:26

What is {n}?

Post by UKenGB »

I know it's name metadata associated with the file, but exactly what name and more importantly, where does it come from?

I had thought it was the name as matched in some on-line db, but I have several small videos that will never match, yet {n} reliably returns the correct name of the video (and as shown in iTunes), whereas media.name and media.title were unreliable. Some files had one or both of these tags, but they didn't allways show when using those media. tags in the format. Yet {n} worked 100%. So where does this come from?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: What is {n}?

Post by rednoah »

What's the command-line call?

Depending on what kind of object you're formatting, it can be the series name, movie name, album name or file name.
:idea: Please read the FAQ and How to Request Help.
UKenGB
Posts: 49
Joined: 04 Jan 2017, 09:26

Re: What is {n}?

Post by UKenGB »

But where does it come from? How does FileBot obtain this? Is it from the embedded tags, which one depending on media type?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: What is {n}?

Post by rednoah »

If you click "Series Mode" then you get Episode matches. If you click "Movie Mode" then you get Movie matches. Depends on what you're doing.

1.
Are you using the GUI? Which database are you using?

2.
Are you using the command-line? What is the command-line call?
:idea: Please read the FAQ and How to Request Help.
UKenGB
Posts: 49
Joined: 04 Jan 2017, 09:26

Re: What is {n}?

Post by UKenGB »

Matches with what, that's the question.

Let's say using a preset with source set as Plain file, on a video file that cannot possibly match with anything on-line (e.g. silly video of my cat). As far as I understand it, this cannot be getting any information from any on-line source. So where is {n} coming from? Is it based on an embedded tag? Or some other arcane piece of information plucked from the ether?

The reason I ask is that with these home videos (not all of my cats :-) they all had a name in iTunes, yet for some of them, MediaInfo did not show any tags with that actual name. However using {n} displayed it in the 'rename to' list in FileBot's RH panel. So how was it getting that information if not on-line and not apparently in any tags that MediaInfo could show?
UKenGB
Posts: 49
Joined: 04 Jan 2017, 09:26

Re: What is {n}?

Post by UKenGB »

I've not started with CLI yet. I want to use the GUI to perfect the format strings to use and then I'll look at transferring to CLI use. But before I do, I want to be sure it's reliable and repeatable.
UKenGB
Posts: 49
Joined: 04 Jan 2017, 09:26

Re: What is {n}?

Post by UKenGB »

It's not just the name that's playing up. Take a look at this file:-

https://dl.dropboxusercontent.com/u/460 ... RECORD.mp4

Here's the MediaInfo output:-

Code: Select all

Complete name                            : /Volumes/JukeBox/Media/Home Videos/Robbie Maddison - New Years Eve 2009 No Limits WORLD RECORD.mp4
Format                                   : MPEG-4
Format profile                           : Sony PSP
Codec ID                                 : MSNV (MSNV)
File size                                : 3.65 MiB
Duration                                 : 1 min 58 s
Overall bit rate mode                    : Variable
Overall bit rate                         : 258 kb/s
Movie name                               : Robbie Maddison - New Years Eve 2009 No Limits WORLD RECORD
Performer                                : Robbie Maddison
Genre                                    : Motors
ContentType                              : Movie
Encoded date                             : UTC 1970-01-01 00:00:00
Tagged date                              : UTC 2017-01-12 14:54:34
Category                                 : motors

Video
ID                                       : 1
Format                                   : MPEG-4 Visual
Format profile                           : Simple@L1
Format settings, BVOP                    : Yes
Format settings, QPel                    : No
Format settings, GMC                     : No warppoints
Format settings, Matrix                  : Default (H.263)
Codec ID                                 : 20
Duration                                 : 1 min 58 s
Bit rate mode                            : Variable
Bit rate                                 : 217 kb/s
Maximum bit rate                         : 424 kb/s
Width                                    : 320 pixels
Height                                   : 218 pixels
Display aspect ratio                     : 3:2
Frame rate mode                          : Constant
Frame rate                               : 30.000 FPS
Color space                              : YUV
Bit depth                                : 8 bits
Scan type                                : Progressive
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.103
Stream size                              : 3.06 MiB (84%)
Writing library                          : vixy.net
Encoded date                             : UTC 1970-01-01 00:00:00
Tagged date                              : UTC 1970-01-01 00:00:00

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : 40
Duration                                 : 1 min 57 s
Bit rate mode                            : Variable
Bit rate                                 : 38.0 kb/s
Maximum bit rate                         : 45.8 kb/s
Channel(s)                               : 2 channels
Channel(s)_Original                      : 1 channel
Channel positions                        : Front: C
Sampling rate                            : 22.05 kHz
Frame rate                               : 21.533 FPS (1024 spf)
Compression mode                         : Lossy
Stream size                              : 545 KiB (15%)
Default                                  : Yes
Alternate group                          : 1
Encoded date                             : UTC 1970-01-01 00:00:00
Tagged date                              : UTC 1970-01-01 00:00:00
You can see clearly that it has the category tag. But this format string:-

Code: Select all

/Volumes/JukeBox/Media/Videos_{media.Category == null?"gen":media.Category}/{n.replaceAll(/[-:\.]/,"_")}{media.Keyword == null?"":" - "+media.Keyword} x {media.Category}
shows media.Category as empty and the conditional test evaluates to null. Any idea what's going on here? Most other videos in this group find the Category tag ok, but this and one or two others remain as null. When I first ran these files, there probably was no Category. Could they be cached somehow?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: What is {n}?

Post by rednoah »

1.
If you use Plain File then the match is always File→File.
If you use TheTVDB then the match is always File→Episode.
If you use ID3 Tags then the match is always File→AudioTrack.

If you use Extended Attributes then it will pluck information from the ether (i.e. xattr metadata) to give you File→ANY matches.


2.
If you format a File→File match then {n} is the current filename. In this case {n} is equivalent to {fn} which is also the current filename.
If you format a File→Episode match then {n} is the serie name. {fn} is the current filename.

You can use bindings like {object} {file} {type} {xattr} {json} in the Format Editor to give you an idea of what you're dealing with.
: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: What is {n}?

Post by rednoah »

media.Category works for me:

Code: Select all

$ filebot -mediainfo *.mp4 --format "{fn} | {media.Category}"
Robbie Maddison - New Years Eve 2009 No Limits WORLD RECORD | motors
Do you get different results on this simple test?


EDIT:

Additional test case for null values:

Code: Select all

$ filebot -mediainfo *.mp4 --format "{fn} | {media.Keyword ?: 'No Keyword'} | {media.Category ?: 'No Category'}"
Robbie Maddison - New Years Eve 2009 No Limits WORLD RECORD | No Keyword | motors
:idea: Please read the FAQ and How to Request Help.
UKenGB
Posts: 49
Joined: 04 Jan 2017, 09:26

Re: What is {n}?

Post by UKenGB »

Works for me too:-

Code: Select all

filebot -mediainfo *.mp4 --format "{fn} | {media.Keyword ?: 'No Keyword'} | {media.Category ?: 'No Category'}" /Volumes/JukeBox/Media/Home\ Videos/Robbie\ Maddison\ -\ New\ Years\ Eve\ 2009\ No\ Limits\ WORLD\ RECORD.mp4 
Robbie Maddison - New Years Eve 2009 No Limits WORLD RECORD | No Keyword | motors
So it's a problem with the GUI. It must be some cached data. How can I clear it all out, history and everything?
UKenGB
Posts: 49
Joined: 04 Jan 2017, 09:26

Re: What is {n}?

Post by UKenGB »

Just that one file in the GUI yields:-

Code: Select all

Robbie Maddison - New Years Eve 2009 No Limits WORLD RECORD | No Keyword | No Category
Just to be clear, that's the same file and same format used in the CLI and the GUI.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: What is {n}?

Post by rednoah »

Are you sure?

Testing with the same file and the same format, I get the same result.
Image

If you quit the app and then start it again, then there's definitely no caching (or open file handles) from previous runs.
:idea: Please read the FAQ and How to Request Help.
UKenGB
Posts: 49
Joined: 04 Jan 2017, 09:26

Re: What is {n}?

Post by UKenGB »

No question that the CLI version seems to always catch the Category and Keywords tags that exist in the file (as shown by MediaInfo, however I view it), but in the GUI it sometimes misses them. It rather looked to me like it was on files that had previously NOT had those tags (I've been messing around with them) and so I thought it was perhaps a cache issue. But I have quit and restarted the app several times and it still refuses to see those tags sometimes, yet the CLI has never missed anything.

Has your app written xattrs to the original file and is now looking there for these tags which were not there when I first ran the process and it's not then looking in the actual file? Just a wild guess as I don't know the inner working of FileBot, but for some reason it is definitely missing these tags sometimes in the GUI.
UKenGB
Posts: 49
Joined: 04 Jan 2017, 09:26

Re: What is {n}?

Post by UKenGB »

Apologies, in current tests with Movies it is picking them up, but yesterday with the small videos, it was playing up. I've done the videos with the CLI though and that was perfect and Movies will go to CLI once I get the format string correct. Trying to get the contents of brackets, without the brackets and only if they exist is doing my head in. :)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: What is {n}?

Post by rednoah »

xattr is not used for MediaInfo. File bindings such as {media} will always read the file content.
:idea: Please read the FAQ and How to Request Help.
Post Reply