Help - Search - Members - Calendar
Full Version: Newbie question about title formatting
Hydrogenaudio Forums > Hosted Forums > foobar2000 > 3rd Party Plugins - (fb2k)
fredhammersmith
Hi...
'Just discovering foobar and all its possibilities.
I'm trying to do some work done with the title formatting feature. Much fun. But there is a problem i do not handle right.
I'm using MP3 Collector for tagging purposes. One of the field i use is the "MusicMatch preference" field, where i store my ratings, from 1 to 5. I am trying to retrieve that info while in foobar, to show in the playlist window, but i have trouble doing that. Probably the fact that there is more than one COMMENT field in most of my files.
The way MP3 Collector work is by storing that info by way of a COMMENT field, beginning with MusicMatch_Preference:rating. For instance, COMMENT FIELD of PARANOID ANDROID: MusicMatch_Preference: 5.0.
For the moment, i just make a playlist of all 5-stars songs and then mass-tag them, creating a TRACKRATING field... then another playlist of all 4-stars songs, and so on... but this is obviously a bit frustrating.
Is there a function that can retrieve just the right info? Checking the COMMENT fields, finding the one that begin with the string i want ("MusicMatch preferences:" in that case) and then return the rating to the right of the ":" character? I can't seem to find the right way.
Can be useful for other uses too.
Thanks to those who knows and can share it!
RedFox
QUOTE(fredhammersmith @ Nov 8 2004, 05:50 PM)
Is there a function that can retrieve just the right info? Checking the COMMENT fields, finding the one that begin with the string i want ("MusicMatch preferences:" in that case) and then return the rating to the right of the ":" character? I can't seem to find the right way.
*

If you use %COMMENT% you'll get what's contained in the comment tags, even if they are more than one. (The function $meta can get you the nth comment tag, but I guess it won't be useful in your case)
With the string you got from %COMMENT%, use the $strstr function that will tell you the position of the string 'MusicMatch preferences:'. Then with $substr you should be able to extract the value that you need.
(Look in titleformat_help.html for reference help on functions and more)
Synthetic Soul
Edit: removed previous attempt as it didn't account for multiple comments.

This is my first (second!) Foobar format string, but I thought I'd give it a go:

CODE
$puts(tagStart,$strstr(%comment%,'MusicMatch_Preference'))
$puts(MMR,$if($greater($get(tagStart),0),$substr(%comment%,$add(23,$get(tagStart)),$add(25,$get(tagStart))),))

Put the above at the beginning of your code.

Then, to get the rating for a song, just use:

CODE
$get(MMR)

This will return the rating if it exists, or nothing if it doesn't.

If you just want to display the value in one place, or use it in one calculation you could use:

CODE
$puts(tagStart,$strstr(%comment%,'MusicMatch_Preference'))
$put(MMR,$if($greater($get(tagStart),0),$substr(%comment%,$add(23,$get(tagStart)),$add(25,$get(tagStart))),))

This will calculate the value and display it at the same time.

NB: this will only work if the format is exactly as described (i.e.: "MusicMatch_Preference", colon, space, 3 character rating).
fredhammersmith
Hi Synthetic Soul...
Thanks for your interest.
Your code doesn't seem to work for the moment, but it may be my mistake.
I'll have time to test it later and i'll get back to you.
Synthetic Soul
QUOTE(fredhammersmith @ Nov 9 2004, 03:18 PM)
Hi Synthetic Soul...
Thanks for your interest.
Your code doesn't seem to work for the moment, but it may be my mistake.
I'll have time to test it later and i'll get back to you.
*
OK, please do.

I tested it in files with no COMMENT fields, one COMMENT field, and files with multiple COMMENT fields in various orders, and it worked fine with all.

As I say, you will need to confirm that all ratings are of the format quoted ("MusicMatch_Preference:" + one space + 3-digit rating).
fredhammersmith
QUOTE(Synthetic Soul @ Nov 9 2004, 11:30 AM)
QUOTE(fredhammersmith @ Nov 9 2004, 03:18 PM)
Hi Synthetic Soul...
Thanks for your interest.
Your code doesn't seem to work for the moment, but it may be my mistake.
I'll have time to test it later and i'll get back to you.
*
OK, please do.

I tested it in files with no COMMENT fields, one COMMENT field, and files with multiple COMMENT fields in various orders, and it worked fine with all.

As I say, you will need to confirm that all ratings are of the format quoted ("MusicMatch_Preference:" + one space + 3-digit rating).
*



My mistake! Works great! Thanks!
Synthetic Soul
No problem - very glad to be of service.

It was a handy excercise to introduce me to the joys of Foobar code. smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.