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: foo_skip: skip tracks that match a specified search query (Read 335930 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: foo_skip: skip tracks that match a specified search query

Reply #650
Is there a way to use wildcards with this component? Thank you.

Re: foo_skip: skip tracks that match a specified search query

Reply #651
The titleformat language or query syntax don't use wildcards, but you can achieve the same result. If you give an example what you want to do with wildcards I can try to explain how to achieve it.

Re: foo_skip: skip tracks that match a specified search query

Reply #652
The titleformat language or query syntax don't use wildcards, but you can achieve the same result. If you give an example what you want to do with wildcards I can try to explain how to achieve it.

I use Foobar to listen to radio stations. But, now some of the stations have introduced very annoying (and long) ads, with titles such as: "Advertisement33a" or "Ad segment", etc. I would like to skip when that happens.

Thank you.

Re: foo_skip: skip tracks that match a specified search query

Reply #653
For example:
Code: [Select]
$stricmp($left(%title%,13),advertisement)$stricmp($left(%title%,3),ad )
This works for titles that begin with words "advertisement" or word "ad". Notice the requirement for space after "ad" to prevent false positives, like word "adventure".

To find those words in the middle of a title you can use something like this:
Code: [Select]
$if($or($strstr($lower(%title%),advertisement),$strstr( $lower(%title%) , ad )),1,)

Re: foo_skip: skip tracks that match a specified search query

Reply #654
Thank you so much! @Case

I've tested it and it works great. :)

Re: foo_skip: skip tracks that match a specified search query

Reply #655
The official component page says: "Skip query also offers $rand() field to generate random number from 0 to 2^32-1.".

Why, then, does neither "$rand() GREATER 2147483648" nor "$rand() LESS 2147483648" skip every second track? Every single track is played.

Re: foo_skip: skip tracks that match a specified search query

Reply #656
I fear this is a limitation with the query syntax. Internally it's handled by converting the $rand() string to actual random number and the resulting query is meaningless to the search filter. It just sees "1234 LESS 2147483648".

But you can use your idea by enabling the option to handle the query as a titleformat string. The string just needs a tiny change: "$ifgreater($rand(),2147483648,1,)".

Re: foo_skip: skip tracks that match a specified search query

Reply #657
Thanks, that works. I find it strange, however, that "1234 LESS 2147483648" isn't just evaluated normally and logically. Isn't that basically an fb2k bug? And why, then, advertise $rand() at all; what's it ever good for in query strings?

Anyways; what I really want to use $rand() for is to play differently rated tracks with different probabilities. I've come up with this solution:

Code: [Select]
$if($not(
// Only play the following.
$and(
$not($meta_test(duplicate)),
$or(
// Play unrated.
$not($meta_test(rating)),
// (Don't play anything rated lower than 3.)
$and(
// Play rating 3 with 50% probability.
$ifequal(%rating%,3,$not($not()),0),
$greater($muldiv(4294967295,50,100),$rand())
),
$and(
// Play rating 4 with 90% probability.
$ifequal(%rating%,4,$not($not()),0),
$greater($muldiv(4294967295,90,100),$rand())
),
$and(
// Play rating 5 with 95% probability.
$ifequal(%rating%,5,$not($not()),0),
$greater($muldiv(4294967295,95,100),$rand())
)
)
)
),1,0)

(BTW: $not($not()) is currently necessary to get boolean true for $and().)

This brings me to the following improvement suggestions for foo_skip:

  • The title formatting documentation says: "Each function becomes a string or number, and/or a truth value (not output)". Is it possible to also support outer truth values, so we can have functions like $not(), $and() or $greater() on the outermost level without the necessity of wrapping it in $if(...,1,0)? If it's not possible by API, the component could perhaps do the wrapping itself.
  • Please support negating the query with a checkbox, meaning: Only play tracks that match the following query.
  • I must develop my query in an external editor, replace the regex "\s" with "" for every iteration of it and store it in a text file I need to keep separately. My above query confusingly becomes: "$if($not($and($not($meta_test(duplicate)),$or($not($meta_test(rating)),$and($ifequal(%rating%,3,$not($not()),0),$greater($muldiv(4294967295,50,100),$rand())),$and($ifequal(%rating%,4,$not($not()),0),$greater($muldiv(4294967295,90,100),$rand())),$and($ifequal(%rating%,5,$not($not()),0),$greater($muldiv(4294967295,95,100),$rand())),))),1,0)". According to the documentation, title formatting strings support comments with //, which is great. If indentation whitespaces make problems, just remove them when building the internal query that's applied. Indenting in the textbox would ideally be easy by pressing tab without going to the next GUI element. And is a monospace font possible like in fb2k's info window?
  • Query strings should be better managable. Currently, there's just a history. But that can make it hard to distinguish between productive strings that you want to go back to and past iterations of those strings that weren't perfect yet. You should be able to name multiple query strings and choose between them. Ideally, there would be a widget like the "Order" drop-down box ("Default" vs. "Repeat" vs. "Shuffle") that contains the defined names, so that one can easily change the skip mode (e.g., "The better the more probable" vs. "Just unrated" to catch up on rating those). The text of the label before the drop-down box should perhaps be freely defineable, because just something like "Skip" wouldn't cut it when the negating checkbox is used. Certain options like "Treat query as titleformat string" and the new negating checkbox would need to be tied to a named query.

Re: foo_skip: skip tracks that match a specified search query

Reply #658
I abuse the library search query quite a bit to bring the simplified syntax for users. You have to remember this is a query language meant to find tracks from library based on their metadata. The example you tried doesn't even touch metadata.

This component is 13 years old. I seem to be unable to remember all the reasons or quirks with all the features that have accumulated. You can utilise the $rand() with query syntax by combining it with other functions: https://hydrogenaud.io/index.php?topic=30361.msg825468#msg825468. Thought either there is a typo in the string I gave in the linked thread or foobar has become picker. The correct example skip query is:
Code: [Select]
"$mod($rand(),3)" IS 0

Note about the history dropdown: you can right click the down arrow to get a context menu which allows you to remove unwanted entries.

Re: foo_skip: skip tracks that match a specified search query

Reply #659
The $mod() variant is interesting. It's nitpicky, but it's also less mathematically sound regarding probability percentages, because 4294967295 is not evenly divisible by 100.

For now, I'll prefix my query strings with something like "$NOT(     Name: Higher Rated More Probable     )", which evaluates to nothing.

The history drop-down context menu is useful and should be documented. It'll still be tedious, though, to do this for every old iteration and you have to fear you'll forget and push your other productive strings too far down, so they disappear.

The "SKIP" tag field value "0:01:25-" and all possible semicolon variants should also be documented. (Is it possible to skip the beginning, multiple fractions in the middle, and the end of a track?)

The following information from the changelog should also be documented on the regular component page: "If the string [when treating query as titleformat string] evaluates to anything but empty string or 0 the track will be skipped."

Then again would it be nice to be able to get from clicking the preferences window's question mark title bar button from the property page of foo_skip to foo_skip online documentation. This works for other components. Therefore, this wiki page, that you reach after clicking the question mark button, must redirect to a dedicated wiki page (search for "foo_skip" in wiki) which, in turn, could link to https://www.foobar2000.org/components/view/foo_skip (quick and easy route) or provide the documentation itself.

Re: foo_skip: skip tracks that match a specified search query

Reply #660
I now have the equivalent in query syntax and with different usage of $muldiv(). Makes it a bit clearer.

Code: [Select]
"#     Name: Higher Rated More Probable     " IS comment OR
NOT (
// Only play the following.
(
rating MISSING

// Play ratings according to different probability percentages.
OR (
%rating% IS 3
AND
"$add(1,$muldiv(100,$rand(),4294967295))" LESS 50
) OR (
%rating% IS 4
AND
"$add(1,$muldiv(100,$rand(),4294967295))" LESS 90
) OR (
%rating% IS 5
AND
"$add(1,$muldiv(100,$rand(),4294967295))" LESS 95
)
) AND
duplicate MISSING
)

I replace the regex "(\R\s*(//.+)?)+" with a space before pasting it in foo_skip's property page.

Re: foo_skip: skip tracks that match a specified search query

Reply #661
I have to limit duration to 30 second when "genre" tag is set to "interlude".

For the time being, I add SKIP tag with "30-" to all track of this genre.

I would like to automatically obtain this duration when genre is interlude (without adding "SKIP" tag).
Anyway to get this result ?

If not today, could it possible to add this feature ?
(for instance with a "virtual" SKIP tag set up in global preference for skip tracks)

Re: foo_skip: skip tracks that match a specified search query

Reply #662
I am at a loss how this plugin works. I have a field called RATING, this field is displayed ok in playlists and on the properties page. Skip track is the first item in my DSP manager. I'm using the latest Foobar2000 version (1.6.10) and the latest skip track version (1.34).
But:
When I set skip to %rating% IS 1 on the preferences page, it doesn't skip anything, but when I choose 'treat as titlequery" it skips all tracks.

I have no need for the other features, I just want to skip tracks I rated 1.
In the playback menu I can select Skip tracks & use bookmarks, but this does not make a difference.
What am I missing?

Re: foo_skip: skip tracks that match a specified search query

Reply #663
Have the same setup and works fine. %rating% IS 1. Titlequery disabled.
 
It does skip tracks with rating = 1 ONLY when playback jumps to such tracks. But not when double clicking on them manually (there is an option for that). Rating comes from playback statistics plugin on my setup though.

Re: foo_skip: skip tracks that match a specified search query

Reply #664
Have the same setup and works fine. %rating% IS 1. Titlequery disabled.
 
It does skip tracks with rating = 1 ONLY when playback jumps to such tracks. But not when double clicking on them manually (there is an option for that). Rating comes from playback statistics plugin on my setup though.

Thanks for your answer. In my case, rating is part of metadata. But when I set rating to 1 in the playback statistics, the track is not skipped either.

Then I tried $meta(rating) IS 1 and tried $meta(%rating%) IS 1
no change.

 

Re: foo_skip: skip tracks that match a specified search query

Reply #665
Code: [Select]
rating IS 1

should do it. The lack of %% means read file tags.

You could use $meta(rating) but you have to wrap it in double quotes when used in queries..

Code: [Select]
"$meta(rating)" IS 1

Re: foo_skip: skip tracks that match a specified search query

Reply #666
Code: [Select]
rating IS 1

should do it. The lack of %% means read file tags.

You could use $meta(rating) but you have to wrap it in double quotes when used in queries..

Code: [Select]
"$meta(rating)" IS 1

Thanks so much for all your and Regors help.
Still can't get it to work though. I play using Simplaylist, could this interfere with the skip plugin?

Re: foo_skip: skip tracks that match a specified search query

Reply #667
Code: [Select]
rating IS 1

should do it. The lack of %% means read file tags.

You could use $meta(rating) but you have to wrap it in double quotes when used in queries..

Code: [Select]
"$meta(rating)" IS 1

Thanks so much for all your and Regors help.
Still can't get it to work though. I play using Simplaylist, could this interfere with the skip plugin?
Don't think so, since foo skip it's on the DSP chain, so it affects anything played no matter the source (now also for streams) or UI.

Anyway there is something wrong on your side since that is not right
Quote
But when I set rating to 1 in the playback statistics, the track is not skipped either.

Are you sure skip is on the dsp? It's silly but maybe you deleted it by error on tests... can't see any other reason.

Re: foo_skip: skip tracks that match a specified search query

Reply #668
This is my DSP chain. Skip track is there.
I really do't get it. I never have problems using and configuring plugins.

Re: foo_skip: skip tracks that match a specified search query

Reply #669
What about your rating tag. Are they really named rating? (in a tagger program or at the properties panel pressing edit on the tag)
Tags may have a name and a different displayed name within Foobar context.

Re: foo_skip: skip tracks that match a specified search query

Reply #670
What about your rating tag. Are they really named rating? (in a tagger program or at the properties panel pressing edit on the tag)
Tags may have a name and a different displayed name within Foobar context.
Thought about that. Simplaylist implements the rating. But there is a Rating field in the metadata:

when editing Rating it says RATING



Re: foo_skip: skip tracks that match a specified search query

Reply #673
What is the difference between rating and <Rating> ?

Items without angle brackets are specially mapped fields, because tag types have special units designed for this data. "Track Number" and "Total Tracks", however, are written into the same unit, originally only intended for the track number.

Items with angle brackets use a generic mechanism of the tag types (like ID3 for .mp3 or MP4 tags for .m4a files) to store any data that hasn't a dedicated unit for it. And the name of the field is written to the file as opposed to the fields previously described.

Using angle brackets for ratings isn't quite correct of fb2k, though. It seems that the fb2k author adopts a new writing style for ratings.

Re: foo_skip: skip tracks that match a specified search query

Reply #674
I wil try to use a new variable as skip criterium tomorrow. See if that works.
Thanks everyone for helping