Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: [help]Masstagger script for rating (Read 3369 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[help]Masstagger script for rating

Hello everyone,
I post here as I could'nt find a masstagger topic.

I'd like to update the Rating in my music files with the code logic described below. I think masstagger is the right tool to do this, but cant' find how to do it 

naming :
db_rating is the rating stored by Playback Statistics (see note 1 below)
tag_rating is the rating stored in the music file in the <RATING> tag

Code: [Select]
IF db_rating exisits 
THEN
   IF db_rating is different than tag_rating  THEN copy db_rating into tag_rating
ELSE
   IF tag_rating exists  THEN copy tag_rating into db_rating
END

(1) when you don't sync to file, Playback Statistics stores the Rating in a database.
%rating% is the value in the db
$meta(rating) is the value in the music file tag
the commands "Import statictics from file tag" and "Write statistics from file tag" are available


anyone kind enough to help ?
thanks
Al

[help]Masstagger script for rating

Reply #1
i don't know if its possible using the masstager, but i'd do it using autoplaylists and the properties dialog (automatically fill values...)
facets would also be an option
i can't give you a proper solution because i think your if-then-else code is somewhat flawed...
if db_rating exists and is different from tag_rating you want to copy the first over the later
however, if they are the same, you want to copy the latter over the first, which does not make any sense, because they are already the same
so i'm a little lost on what exactly you want

[help]Masstagger script for rating

Reply #2
Dont know how what field should be used for the db rating field in masstagger.

Now for just checking the two fields and in case if they are unequal then to replace the file tag with the Rating_DB try this

////////THIS WILL FULFILL YOUR FIRST CONDITION

Code: [Select]
$if($greater(%rating%,0),$if($greater($mod(%rating%,$meta(rating)),0),%rating%,$meta(rating)),$meta(rating))


Note: Please double check the output first

/////////THIS WOULD BE USEFUL FOR THE ELSE PART i.e. copying the db value to the file tag if the db value doesn't exist (as suggested by ruebe above)

1. make an autoplaylist using this %RATING% LESS 1

2. select all the tracks of the autoplaylist.

3. Import statistics from file tags.

[help]Masstagger script for rating

Reply #3
thanks your quick  responses.
I can't edit my post anymore. Here is the code again with brackets to identify where the ELSE clause belongs.


Code: [Select]
IF db_rating exists 
THEN
   [IF db_rating is different than tag_rating  THEN copy db_rating into tag_rating]
ELSE
   [IF tag_rating exists  THEN copy tag_rating into db_rating]
END


The goal of the script is that both db and file tag become identical and update only those who are different.

Unfortunately I can't update all tags massively from db value. I need to update only those who have a different value (ie those I changed). This is because I have multiple foobar instances and sync files that changed. If I update massively, it will create a lot of "false positive".

@ruebe : autoplaylist is a good idea. How would you create a query with criteria $meta(rating) is not equal to %rating%.


@prateek : something I miss about masstagger : where should I put the titleformat string you suggest ?

[help]Masstagger script for rating

Reply #4
@alkasar
When the masstagger box opens click on add button and then
Format value from other fields
          Put RATING in Destination Field Name and script in the formatting pattern.

Perform as i told earlier, it will make your ratings identical. But be cautious

[help]Masstagger script for rating

Reply #5
Quote from: alkasar link=msg=8051115 date=
I post here as I could'nt find a masstagger topic.
Masstagger is first-party, not third-party, so I’ve moved this to General accordingly.

[help]Masstagger script for rating

Reply #6
@ruebe : autoplaylist is a good idea. How would you create a query with criteria $meta(rating) is not equal to %rating%.

$meta(rating) PRESENT AND rating PRESENT
then i'd set up a column in playlist view: $greater($meta(rating),rating) and sort by that column

however, i don't know if this works as i think it does...i'm not a big fan of the $meta stuff and so i avoid using tags that make use of if it

[help]Masstagger script for rating

Reply #7
sorry for posting at the wrong place.

@ruebe : after some tries, the correct query syntax is
(%rating% PRESENT) AND (rating MISSING) to find the tracks having a database rating but no tag rating.
when a field name is used without %, some operators of query syntax considers it is meta field.

Too bad that query can not compare two fields ! it would be great if query syntax would accept this :
NOT (rating EQUAL %rating%)

instead, this very_long_and_stupid_query works

(%rating% PRESENT) AND NOT (((rating EQUAL 1) AND (%rating% EQUAL 1)) OR ((rating EQUAL 2) AND (%rating% EQUAL 2)) OR ((rating EQUAL 3) AND (%rating% EQUAL 3))  OR ((rating EQUAL 4) AND (%rating% EQUAL 4))  OR ((rating EQUAL 5) AND (%rating% EQUAL 5)))


@prateek : got it. thanks. will try this tomorrow:)

[help]Masstagger script for rating

Reply #8
great, that you could figure it out on your own
just a little warning, if you have too many library viewers and autoplaylists with very_long_and_stupid_queries, foobar may get sluggsish (at start-up and when moving files)
thus, maybe a simpler autoplaylist with forced sorting or a special grouping may be better in the long run

btw: it is indeed a pitty, that something like "NOT (rating EQUAL %rating%)" can not be queried...feature request!

[help]Masstagger script for rating

Reply #9
you both helped me open my mind about other ways to resolve my issue

my feature request to Peter is to enhance the Playback Statistics component !
IMHO, Rating is not a playback statistics and many people want to keep it in the tags (think of people copying music to their portable players).
Unfortunately, Playback statistics copies either all stats to file tag or none. I asked to add an option to copy only Rating to file, not the others statistics.


query syntax is indeed "static". you can only compare fields to values (string or number) not another field :-( a better UI would also help !
Too bad that history of queries is not kept.

BTW, is there a way to store queries (other than create an autoplaylist) ?

 

[help]Masstagger script for rating

Reply #10
1. it is certainly possible to store ratings in tags...mine are stores in %rat%...this way i don't have to rely on a database and avoid issues with $meta...the downside is no other media player (portable or software) can access those ratings, but i don't care, because most of the players use their own rating scheme anyway
2. i believe, that there is somewhere a WSH-script that lets you store queries...furthermore, IIRC, the esplaylist- and the quicksearch-component have a query history