INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Globale variable and custom library fieds  (Read 2217 times)

minolotus

  • Junior Woodchuck
  • **
  • Posts: 93
Globale variable and custom library fieds
« on: January 04, 2013, 03:26:32 pm »

Good afternoon and a happy new year!

I have a short question regarding the global variable. First I added a new pane with an album track counter as described by MrC in this post (Generating album track count). That worked without problems. After that I replaced the fields [album artist (auto)] and [album] in the variable name by a custom library field with calculated data (The field stores the file name without the file extension). But that didn’t give me the expected result as the column with the load expression showed for all files zero?

 Is it possible that I can’t use custom library fields with calculated data with the name of the global variable?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Globale variable and custom library fieds
« Reply #1 on: January 04, 2013, 04:19:43 pm »

It is not a problem to use expressions in Calculated data, including the global variables.  One caveat here - the values stored inside the global are typically undefined until some Search sets the values.

Here's an example that creates an Albums Per Artist pane:

The Search rule segment to set the value:

[=save(0,v_tracks[album artist (auto)][album])1]=1 [=ifelse(Compare([track #].[disc #], <=, 1.1),save(0,v_artists_[album artist (auto)]))1]=1 [=ifelse(Compare([track #].[disc #], <=, 1.1),save(math(1+load(v_artists_[album artist (auto)])),v_artists_[album artist (auto)]))1]=1

The view's rule:

   [# Albums per Artist] : [album artist (auto)]\[Album]&datatype=[list]

The [# Albums per Artist] field:

   load(v_artists_[album artist (auto)])

See attached images.

Can you describe what you're trying to do?
Logged
The opinions I express represent my own folly.

minolotus

  • Junior Woodchuck
  • **
  • Posts: 93
Re: Globale variable and custom library fieds
« Reply #2 on: January 04, 2013, 05:18:12 pm »

Thanks for your answer!

My idea was to build a field that shows me whether I have a (external) subtitle file for a media file or not. All my subtitle files are located in the same folder as the respective media file and they have always the same file name as the media file.  First I have imported the subtitle files as document files into the library. Then I added a custom library field [_SubtitleName] to the database with calculated data: left([Filename], math(length([Filename])-4)).

In the next step I wanted to use a global variable to count if there is more than one file with the same [_SubtitleName]. If I have two files with the same [_SubtitleName],  it is likely that one is a media file and the other is the subtitle file. I added the following string to the import/export field: [=save(0,v_tracks[_SubtitleName])1]=1 [=save(math(1+load(v_tracks[_SubtitleName])),v_tracks[_SubtitleName])1]=1 [Media Type]=[Data],[Video].

And in the expression column I put the following: load(v_tracks[_SubtitleName]).

The result for all files is 0? I still don’t understand where the problem is  ?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Globale variable and custom library fieds
« Reply #3 on: January 04, 2013, 05:50:14 pm »

If this is going to be a maintenance view, that you use only periodically, you can use the IsMissing() function, basing the subtitle filename on the modified filename that exists in the library.  

For example, in a panes view, output two groups: one with files missing subtitles and one with files that have subtitles.

Pro's and Cons: IsMissing() is slow, as it acts on the filesystem.  But you don't have to import your subtitles at all.

Panes column expression:

   if(ismissing(removeright([Filename], 4).XYZ), No Subtitle file, Subtitle file exists)

where XYZ is your subtitle file's prefix.
Logged
The opinions I express represent my own folly.

minolotus

  • Junior Woodchuck
  • **
  • Posts: 93
Re: Globale variable and custom library fieds
« Reply #4 on: January 04, 2013, 06:33:01 pm »

Thank you, that is doing the job! As I don't need to check this every day, it is no big deal that ismissing() is so sloooow.  :)
Logged

yannis

  • World Citizen
  • ***
  • Posts: 229
Re: Globale variable and custom library fieds
« Reply #5 on: January 16, 2013, 03:05:49 pm »

Hey, MrC, while you're at it, is there a way to use an expression in the Fill Properties from Filename in order to fill in a column (maybe Comment or Notes) with the available subs? When I'm choosing a film to watch with friends, it's great to sort my films "by subs" first.

I have both mkv's with embedded subs and some older avi's with a sidecar srt. Some subs are in Greek, some in English. A few films have both Eng and Gr srt, some have none. The naming convention is
    Director - Title - Year.avi
    Director - Title - Year.ENG.srt

What's the best way to create a view with only the films with GR subs or the Eng subs etc? And then how do I make it visible in Theater View?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Globale variable and custom library fieds
« Reply #6 on: January 16, 2013, 06:02:47 pm »

Fill Properties from Filename doesn't use expressions, so this wouldn't be the tool to use.

But a view can be created that asks simple questions such as "Does this file name exist in the file system?", and output some value based on that result.  So its easy to test for the existence of a file, or two, or three...

What isn't possible is to ask MC to find all possible files that meet some criteria (such as a wildcarded *.srt).  These files themselves would need to be imported, and then such files could be enumerated.

So if you have, lets say, three possible languages, and the files are well named and can be derived from the imported movie name, you can get MC to indicate this.

I don't know how to ask MC if a subtitle is embedded; this doesn't seem known until the movie is actively being decoded.

If your GR subtitles are in sidecar files, and their names can be derived from the movie, like your ENG example above, then this is pretty easy.

I'll wait to hear your responses before providing a solution...
Logged
The opinions I express represent my own folly.

yannis

  • World Citizen
  • ***
  • Posts: 229
Re: Globale variable and custom library fieds
« Reply #7 on: January 17, 2013, 12:58:30 am »

>Fill Properties from Filename doesn't use expressions, so this wouldn't be the tool to use.

Right; I just mentioned Fill Properties because I thought that for a filename like "Dir - Name - Year.LANG.avi" it would be easy to send the LANG string in a given field. The question is how could I copy the LANG string from the SRT file name to the video file name - either in MC or with an external renaming program.

For example, couldn't MC use a routine to import both AVI + SRT, check for dupe names, and then Move the LANG from the SRT to the respective AVI and delete the SRT entry?



>>So if you have, lets say, three possible languages, and the files are well named and can be derived from the imported movie name, you can get MC to indicate this.

I wouldn't mind I if I had to keep only one ref to the SRTs (if Gr + Eng SRTs present >> keep GR)



>>I don't know how to ask MC if a subtitle is embedded; this doesn't seem known until the movie is actively being decoded.

That could possibly be a feature request; The same way as Audio is analysed, video files could be "read" and streams (audio+subs) could be filled in accordingly. I've been using for years a tool called Extreme Movie Manager that does a decent job at that while importing new films.



>>If your GR subtitles are in sidecar files, and their names can be derived from the movie, like your ENG example above, then this is pretty easy.

So how could I go about it?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Globale variable and custom library fieds
« Reply #8 on: January 17, 2013, 02:09:47 am »

This is a chicken and egg problem, assuming you have not imported subtitle files.

MC has your video file and its name:

   Director - Title - Year.avi

There is no LANG component.  But the trick to getting MC to ask about a file NOT in its library is to derive a name from what you have, and ask MC if the file exists:

   if(!IsMissing(Director - Title - Year.ENG.srt), ....

Note: I'm ignoring how we create that name above, as the expression is pretty easy.

Well, since you've specifically asked MC about the ENG subtitle file, you know already that the language would be ENG!  So the expression to use to assign to your language field would be:

   =if(!IsMissing(Director - Title - Year.ENG.srt), ENG,,)

That's not terribly useful by itself, since you could just assign ENG to your language field (so long as a subtitle file exists).  To be more useful, you'd have to make a more complex expression, testing for different languages, each sub-expression returning the language value.  This would allow you to select a bunch of video files and do a bulk assignment.  This is what you wanted from File Properties from Filename.  Pseudocode ahead:

   =ifelse(!IsMissing(Director - Title - Year.ENG.srt), ENG,
              !IsMissing(Director - Title - Year.GR.srt), GR,
              ...
      )

The more tests you add, the slower the performance because MC's IsMissing() function has to check the file system for each and every file, each time it is used.
Logged
The opinions I express represent my own folly.

yannis

  • World Citizen
  • ***
  • Posts: 229
Re: Globale variable and custom library fieds
« Reply #9 on: January 17, 2013, 03:16:43 am »

I get the idea, thanks. I'll try to experiment; at the moment I'm reading more on scrapping, to see if it's really worth it, as I'm not really satisfied with the results I'm getting so far.

It seems easier though to use BulkRename to append LANG in the filename of a bunch of files and then import them in XMM.
Logged
Pages: [1]   Go Up