Rockbox Technical Forums

Support and General Use => Audio Playback, Database and Playlists => Topic started by: afruff23 on October 05, 2006, 05:23:32 PM

Title: Creating custom Tagcache query?
Post by: afruff23 on October 05, 2006, 05:23:32 PM
The tagnavi.config syntax is very confusing, even with that guide in the wiki. Any help is appreciated. Thanks.

Hi, I would like to create a tagcache menu item called "Electronica". I would like it to work by adding any songs tagged with house, trance, electronica, IDM, etc. (I have many other genres, but an example consisting of more than 2 genres under this menu item will help me do the rest on my own). The menu item should be called "Electronica" as stated before. The first level should display artists. The second level should display albums. The third level should display tracks.

Also, I would like to create another tagcache menu item called "Genre Albums". This would have the first level be genres. The second level would be albums. The third level should display tracks.

Thanks again.
Title: Re: Creating custom Tagcache query?
Post by: bascule on October 06, 2006, 05:39:25 AM
--#1--
The tagnavi.config syntax is very confusing, even with that guide in the wiki. Any help is appreciated. Thanks.
The Wiki has not yet been updated with the V 2.0 syntax changes...
Quote
When I am having more time next month I was planning to update the wiki (unless someone beats me to it).

--#2--
Hi, I would like to create a tagcache menu item called "Electronica". I would like it to work by adding any songs tagged with house, trance, electronica, IDM, etc. (I have many other genres, but an example consisting of more than 2 genres under this menu item will help me do the rest on my own). The first level should display artists. The second level should display albums. The third level should display tracks.

I think this should work, but I haven't tested it ;)
Code: [Select]
"Electronica"  -> artist ? genre = "house" & genre = "trance" & genre = "IDM" -> album -> title = "%02d %s" tracknum title
--#3--
Also, I would like to create another tagcache menu item called "Genre Albums". This would have the first level be genres. The second level would be albums. The third level should display tracks.

This will work:
Code: [Select]
"Genre Albums"        -> genre -> album -> title = "%02d %s" tracknum title
Title: Re: Creating custom Tagcache query?
Post by: roolku on October 06, 2006, 05:59:35 AM
The Wiki has not yet been updated with the V 2.0 syntax changes...

Maybe I can find some time today...

Quote
I think this should work, but I haven't tested it ;)
Code: [Select]
"Electronica"  -> artist ? genre = "house" & genre = "trance" & genre = "IDM" -> album -> title = "%02d %s" tracknum title

Unfortunately this won't work. It should be

Quote
I think this should work, but I haven't tested it ;)
Code: [Select]
"Electronica"  -> artist ? genre = "house" | genre = "trance" | genre = "IDM" -> album -> title = "%02d %s" tracknum title

However the | (OR) operator has not been implemented (yet). Unfortunatly this is not easy to do either.

For your special case I can envision a "oneof" operator, where you supply a list of possible values e.g.

Code: [Select]
"Electronica"  -> artist ? genre oneof "house|trance|IDM" -> album -> title = "%02d %s" tracknum title
I might give it a try and make a patch to see how well it works.
Title: Re: Creating custom Tagcache query?
Post by: bascule on October 06, 2006, 06:14:36 AM
Quote from: roolku
Unfortunately this won't work.

Of course it won't, I was forgetting my database queries logic there :)  Thanks for putting me straight. Oh well, one out of two isn't too bad.
Title: Re: Creating custom Tagcache query?
Post by: ww2- on October 06, 2006, 07:37:27 AM
The Wiki has not yet been updated with the V 2.0 syntax changes...

Maybe I can find some time today...

Please do. =)
Title: Re: Creating custom Tagcache query?
Post by: roolku on October 06, 2006, 09:22:27 AM
Please do. =)

Okay, I have made a start. I think everything is covered, but it could probably do with some clarification and examples. If you find any errors please let me know (or fix them on the wiki)

Cheers
Title: Re: Creating custom Tagcache query?
Post by: bascule on October 06, 2006, 11:12:56 AM
Thanks for that roolku, it looks pretty comprehensive to me.
Title: Re: Creating custom Tagcache query?
Post by: afruff23 on October 06, 2006, 05:38:50 PM
Thank you for updating the wiki. It's a bit clearer now. An "or" or "oneof" operator would be great.
Title: Re: Creating custom Tagcache query?
Post by: roolku on October 06, 2006, 07:44:41 PM
Thank you for updating the wiki. It's a bit clearer now.

A pleasure.

Quote
An "or" or "oneof" operator would be great.

Here you go: http://www.rockbox.org/tracker/task/6137  :)
Title: Re: Creating custom Tagcache query?
Post by: afruff23 on October 06, 2006, 08:20:43 PM
Thank you! Do you think this will ever get into CVS builds?
Title: Re: Creating custom Tagcache query?
Post by: bascule on October 07, 2006, 02:17:11 PM
So what's all this then...?
Quote from: roolku in the TagCache Wiki
...followed by a heading (in quotes). The heading is displayed if the option is enabled in the settings...

I wondered why the menu name was mentioned twice, but I can find no such setting in the menus or a freshly-created .cfg file.

Is this done via some mysterious other config file?

I'd really like to be be able to have a title/heading for  the Tag Cache menus.
Title: Re: Creating custom Tagcache query?
Post by: roolku on October 07, 2006, 04:56:44 PM
Thank you! Do you think this will ever get into CVS builds?

Your guess is as good as mine. :)
As far as I can see I haven't violated any quidelines, so it is just a case of a developer (Slasheri?) knowing about and liking it.

So what's all this then...?
Quote from: roolku in the TagCache Wiki
...followed by a heading (in quotes). The heading is displayed if the option is enabled in the settings...

I wondered why the menu name was mentioned twice, but I can find no such setting in the menus or a freshly-created .cfg file.

Is this done via some mysterious other config file?

I'd really like to be be able to have a title/heading for  the Tag Cache menus.

General Settings/File View/Show Path :)

Not the most obvious setting I suppose...

Title: Re: Creating custom Tagcache query?
Post by: bascule on October 08, 2006, 04:01:35 PM
General Settings/File View/Show Path :)

Not the most obvious setting I suppose...


No, it's not, but it works a treat... thanks!
I had always assumed that Show Path was just for the File Browser, not Tag Cache.
Title: Re: Creating custom Tagcache query?
Post by: roolku on October 09, 2006, 07:54:35 AM
Thank you! Do you think this will ever get into CVS builds?

I just got the email that it has been accepted.

better go and update the wiki...
Title: Re: Creating custom Tagcache query?
Post by: afruff23 on October 09, 2006, 05:03:05 PM
Thank you so much!

However, I seem to be having a prolem. I did not edit the tagnavi.config file. The changes are all in tagnavi_custom.config

This line:
Code: [Select]
"Electronica Artists" -> artist ? genre @ "Ambient|Big Beat|Breakbeat|Breaks|Electronic|House|IDM|Psychedelic|Rave|Techno|Trance|Electronica|Synthpop" -> album -> title = "%02d. %s" tracknum title
does not work. Instead, it displays ALL artists(not excluding any). Whenever you select an artist, the cursor moves back to the top of the list.

This does work however:
Code: [Select]
"A" -> artist ? genre @ "Progressive Rock|Trance" -> album -> title = "%02d. %s" tracknum title
There are no extraneous spaces or end of lines in case you are wondering.
Title: Re: Creating custom Tagcache query?
Post by: afruff23 on October 09, 2006, 05:19:05 PM
I discovered the problem by looking at the patch code and trial % error: you can't specify a list of more than 3 values. Is there any way to remove this limit, or allow the user to set this limit?
Title: Re: Creating custom Tagcache query?
Post by: afruff23 on October 09, 2006, 05:31:27 PM
Bug report here (http://www.rockbox.org/tracker/task/6155).
Title: Re: Creating custom Tagcache query?
Post by: roolku on October 09, 2006, 06:40:58 PM
I discovered the problem by looking at the patch code and trial % error: you can't specify a list of more than 3 values. Is there any way to remove this limit, or allow the user to set this limit?

Well, there is no intentional limit in the number of items, but I can confirm the problem. The function seems to return true for all cases for long lists. Which is odd, as it doesn't do it in my testbed outside rockbox. I suspect a buffer overflow and will investigate further.....

EDIT: I have uploaded a patch to the tracker.
Title: Re: Creating custom Tagcache query?
Post by: afruff23 on October 10, 2006, 12:06:25 AM
Could you please submit this patch separately so it gets noticed? Also, can you allow the user to set the limit to their own will like maximum playlist sizes? Thanks again.
Title: Re: Creating custom Tagcache query?
Post by: roolku on October 10, 2006, 04:55:10 AM
Could you please submit this patch separately so it gets noticed?
I don't think the developers would appreciate that. If you want to get it in, you could talk to slasheri on irc.

Quote
Also, can you allow the user to set the limit to their own will like maximum playlist sizes?

From experience that would have no chance of getting into cvs. I think 128 bytes is a good compromise.

EDIT: now in cvs
Title: Re: Creating custom Tagcache query?
Post by: afruff23 on October 10, 2006, 02:42:16 PM
Thanks very much!
Title: Re: Creating custom Tagcache query?
Post by: afruff23 on October 10, 2006, 03:51:59 PM
It doesn't work. :(
Title: Re: Creating custom Tagcache query?
Post by: afruff23 on October 10, 2006, 03:59:36 PM
When my original playlists didn't work, I tried another one:
Code: [Select]
"A" -> artist ? genre @ "Classic Rock|Grunge|Rock" -> album -> title = "%02d. %s" tracknum title
This works, but over 32 characters does not, so the following does not work:
Code: [Select]
"B" -> artist ? genre @ "Classic Rock|Grunge|Progressive Rock" -> album -> title = "%02d. %s" tracknum title
This works:

Code: [Select]
"C" -> artist ? genre @ "Hard Rock|Grunge|Rock|Metal" -> album -> title = "%02d. %s" tracknum title

So, the 32 character limit is still in place. Obviously I'm using the bleeding edge build.
Title: Re: Creating custom Tagcache query?
Post by: roolku on October 10, 2006, 08:47:54 PM
Yup, I was just about to tell you that your example worked fine for me, when I realised that I had posted the wrong patch. :(

Here is the corrective patch.

[attachment deleted by admin, too old]
Title: Re: Creating custom Tagcache query?
Post by: afruff23 on October 10, 2006, 08:52:01 PM
You had better tell Miika Pekkarinen. He committed that other patch. If I knew how to contact him, I would do it myself. Sorry. Or you could submit this patch yourself. Thanks again for all the work.
Title: Re: Creating custom Tagcache query?
Post by: Febs on October 10, 2006, 09:35:27 PM
The best way to contact him is on IRC.  He uses the name Slasheri.
Title: Re: Creating custom Tagcache query?
Post by: afruff23 on October 10, 2006, 09:52:16 PM
Oh right. Forgot about that. Going now...
Title: Re: Creating custom Tagcache query?
Post by: afruff23 on October 11, 2006, 06:30:01 AM
It should work now. I'll test later today.
Title: Re: Creating custom Tagcache query?
Post by: afruff23 on October 11, 2006, 03:12:26 PM
It works! Thanks a lot to roolku and slasheri for their hard work. Rockbox is now the only DAP software which allows for instant creation of smart playlists (albeit rather simple).
Title: Re: Creating custom Tagcache query?
Post by: bascule on October 14, 2006, 05:41:28 AM
Some new questions:

I've successfully got my custom tagnavi working, with a couple of exceptions. I'm not sure if they are bugs or not.

I'm trying to add a line to display all artists beginning with non-alphabetic characters (911, 50 Cent etc.). I don't just want to look for artists beginning with 0 to 9, as that may exclude some bizarre entries beginning with other characters.

I've tried the following lines and they both only exclude the first query term:
Code: [Select]
"Non-Alphabetical A-E"   -> artist ? artist !^ "A" & !^ "B" & !^ "C" & !^ "D" & !^ "E" -> album  -> title = "%02d %s" tracknum titleThis lists all artists except those beginning with 'A'

Code: [Select]
"Non-Alphabetical B&C"   -> artist ? artist !^ "B" & !^ "C" -> album  -> title = "%02d %s" tracknum titleThis lists all artists except those beginning with 'B'

It seems that multiple negative queries (does NOT begin with "A" AND does not NOT begin with "B" AND does NOT etc...) do not work correctly.

Similarly, I'm trying to separately list artists beginning with 'T', but not 'The ' and those solely beginning with 'The '

I've tried the following lines
Code: [Select]
"T1"   -> artist ? artist !^ "The " & ^ "T" -> album  -> title = "%02d %s" tracknum titleThis lists all artists except those beginning with 'The '

Code: [Select]
"T2"   -> artist ? artist ^ "T" & !^ "The " -> album  -> title = "%02d %s" tracknum titleThis lists all artists beginning with 'T', but includes all those beginning with 'The ', which it shouldn't.

It seems like the same problem as above, that concatenated search queries are broken if one of them is a NOT query.

Can anyone confirm, deny or put me straight on this one? If confirmed, I'll raise a bug.
Title: Re: Creating custom Tagcache query?
Post by: Slasher on October 14, 2006, 08:20:06 AM
Please try with the following syntax:
Code: [Select]
"Non-Alphabetical B&C"   -> artist ? artist !^ "B" & artist !^ "C" -> album  -> title = "%02d %s" tracknum title

That's because it's possible to include different tags in one search clause.
Title: Re: Creating custom Tagcache query?
Post by: bascule on October 14, 2006, 12:34:23 PM
D'oh!

Of course. It's so simple and if I'd not had 'code-blindness' when I looked at roolku's original, I would have seen how it worked. Thanks very much.

That's solved the 'T vs The' problem.

It would also fix the other problem, but I've come up with a neater solution by using less than:

Quote from: bascule link=topic=6866.msg54399#msg54399
I'm trying to add a line to display all artists beginning with non-alphabetic characters (911, 50 Cent etc.). I don't just want to look for artists beginning with 0 to 9, as that may exclude some bizarre entries beginning with other characters.

Code: [Select]
"Non-alpha"   -> artist ? artist < "A" -> album  -> title = "%02d %s" tracknum title
This certainly works on numerics, have not yet created a test file for non-alphanumerics such as # or ! ... ;)
Title: Re: Creating custom Tagcache query?
Post by: roolku on October 15, 2006, 05:15:02 AM
Please try with the following syntax:
Code: [Select]
"Non-Alphabetical B&C"   -> artist ? artist !^ "B" & artist !^ "C" -> album  -> title = "%02d %s" tracknum title

That's because it's possible to include different tags in one search clause.

Unfortunately this still doesn't work for the case in question, as there is a limit  (I think 16) on how many clauses one can have and there are 26 letters. And I guess Amicon wouldn't like another size increase...

Quote from: bascule link=topic=6866.msg54399#msg54399
I'm trying to add a line to display all artists beginning with non-alphabetic characters (911, 50 Cent etc.). I don't just want to look for artists beginning with 0 to 9, as that may exclude some bizarre entries beginning with other characters.

Code: [Select]
"Non-alpha"   -> artist ? artist < "A" -> album  -> title = "%02d %s" tracknum title
This certainly works on numerics, have not yet created a test file for non-alphanumerics such as # or ! ... ;)

That is exactly the case I created patch #6098 for (which Slasheri kindly comitted). It works with punctuation and so on, but it doesn't catch various unicode characters. For ASCII (and most European languages) you should be okay.

Maybe we could start sharing our tagnavi.config files so we can get inspiration from each other. I have included my current one here.

[attachment deleted by admin, too old]
Title: Re: Creating custom Tagcache query?
Post by: bascule on October 15, 2006, 01:25:36 PM
Quote from: roolku
Unfortunately this still doesn't work for the case in question, as there is a limit  (I think 16) on how many clauses one can have and there are 26 letters.

So, I presume that's different from the (recently increased (http://www.rockbox.org/tracker/task/6155)) overall 128-byte limit for a query string?

I'm hoping you can clear this up. Can you have 16 128-byte clauses, or 16 clauses with a total length of 128 bytes?

And what bit of the line exactly constitutes the 'query clause'?

Anyway, currently I'm happy with the < "A" solution :D
Title: Re: Creating custom Tagcache query?
Post by: roolku on October 15, 2006, 02:39:03 PM
So, I presume that's different from the (recently increased (http://www.rockbox.org/tracker/task/6155)) overall 128-byte limit for a query string?

The 128 byte limit is for individual strings (the things between ")

Quote
I'm hoping you can clear this up. Can you have 16 128-byte clauses, or 16 clauses with a total length of 128 bytes?

16 clauses with 128 bytes before and 128 bytes after the operator

Quote
And what bit of the line exactly constitutes the 'query clause'?

"tag" "operator" "constant string"

You can have several of these seperated by & (and). They are used as conditions to reduce the result set.

But this might all be out of date with Slasheri's latest update. I'll will change the Wiki when I am back from my holidays.
Title: Re: Creating custom Tagcache query?
Post by: Yotto on October 15, 2006, 06:58:35 PM
Anyway, currently I'm happy with the < "A" solution :D

Couldn't you do 2 clauses:

< "A"
> "Z"
Title: Re: Creating custom Tagcache query?
Post by: afruff23 on October 16, 2006, 01:37:01 AM
Lol, what are your holidays?

Does Slasheri's latest tagcache update break anything?
Title: Re: Creating custom Tagcache query?
Post by: afruff23 on November 11, 2006, 11:22:19 PM
How do you make a recently added query? WHat about a list of compilation albums? Or is this not possible?
Title: Re: Creating custom Tagcache query?
Post by: roolku on November 12, 2006, 01:23:23 PM
How do you make a recently added query?

You can't. Even if you created an additional tag for file date, the problem would be that the file date doesn't signify when a file was uploaded, but when it was created (or modified).

My workaround is to have:

"not played"    -> artist ? playcount == "0" -> album -> title

But obviously this only works until you have listened to the song.

I can't see a reliable way to detect a "recently added" file - do you have a suggestion?

WHat about a list of compilation albums? Or is this not possible?

Only if you tagged them consistently somehow. E.g. you could use patch http://www.rockbox.org/tracker/task/6301  and put "compilation" in the comment tag.

"Compilations" -> album ? comment = "compilation" -> title

(if you don't want to use this patch, I suppose you could abuse the composer field).

Title: Re: Creating custom Tagcache query?
Post by: Llorean on November 12, 2006, 02:17:18 PM
Why not have TagCache include a counter of some sort, as songs are added, it increments the counter for each new "set".

Songs added during initiation get the value 0. Each time new songs are detected they get an incremented value, so if you add 50 songs to your player, when TC updates and sees them they all have value 1. Then 2, and so on. Recently added can either be all songs with the current value, or maybe the last X values.
Title: Re: Creating custom Tagcache query?
Post by: afruff23 on February 14, 2007, 12:19:15 AM
Hehe, don't tell me. You're the knowledgeable developer. If you want, I could fill out the feature request.