Grouping Genres

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Grouping Genres

by Pablo » Mon Apr 17, 2006 2:41 pm

Steegy wrote:Well actually, there is. Look at the BrowseToNode function in the StartupNode and FavouriteNodes scripts.
Thanks for letting me know, this could be useful in other instances :) .
Steegy wrote:If you are interested in adding this, I always want to code that piece. (It's looks not so difficult anyway :) )
Sure, that would be great since you obviously understand this better than me. But it would be better if you wait for the new version of MN to come along because I'm introducing some substantial changes in the structure of the script (well, trying to, not sure it's going to work).
Steegy wrote:Or, it's because the Jet Engine throws an error that MediaMonkey doesn't handle correcly and so goes 100%.
I tried the problematic SQL query in MsAccess and it works (very fast).
I tried it using manual DB connectivity (using ADODB.Connection object), and the Jet Engine returns an error...
So it's probably an error in MediaMonkey, and not in the specifically the Jet Engine (which doesn't execute correctly, but does give a correct error).
I think you should post this in the bugs forum... (still, Jet throws an error while MS Access runs the query no problem)

by Steegy » Mon Apr 17, 2006 8:39 am

The problem is there's no way to access an arbitrary node.
Well actually, there is. Look at the BrowseToNode function in the StartupNode and FavouriteNodes scripts.

This function tries to go to the specified node and then uses the reference of the found node to set it as current node.
You could change it just a little bit by replacing

Code: Select all

If Err <> 0 Then Exit Function
by

Code: Select all

If Err <> 0 Then
  CreateTheNodeStructure
Exit Function
so that instead of just leaving the function returning false (when a node in the node structure specification doesn't exist), it would start another method to create that node, and the specified subnodes.

When the function finishes, the node reference would always be available (by browsing to it or by adding it), so from then on you could use Magic Nodes to use that node reference as parent for the custom node structure.


Example:
:: "parent" specification in custom node1 = "Library>Genre Groups>Rock"
:: "parent" specification in custom node2 = "Library>Genre Groups>Pop"
For the first node, the BrowseToNode would run to the "Library" node, and because it doesn't find the subnode Genre Groups, it will add the rest of the structure: "Genre Groups>Rock".
For the second node (so "Library>Genre Groups" already exists), the BrowseToNode would run to the "Library>Genre Groups" node, and because it doesn't find the subnode "Pop", it will add the rest of the structure: "Pop".


A special specification like "parent:%genre%>Genre Groups>Rock" would enable the script to begin searching from the built-in Genre node (with available reference). The only reasonable purpose of this would be that the nodes then still work correctly even if the MM language is changed.
So you could use "parent:%artist%>NewNode" for all languages, instead of "parent:Library>Artist>NewNode" in English and "parent:Library>Artiest>NewNode" in Dutch.
This behaviour would be a combination of FavouriteNodes/StartupNode version 1, and the current versions.

If you are interested in adding this, I always want to code that piece. (It's looks not so difficult anyway :) )

+++++++++++++++
So I believe Access has some built-in protection against redundant code while JET doesn't.
Or, it's because the Jet Engine throws an error that MediaMonkey doesn't handle correcly and so goes 100%.
I tried the problematic SQL query in MsAccess and it works (very fast).
I tried it using manual DB connectivity (using ADODB.Connection object), and the Jet Engine returns an error...
So it's probably an error in MediaMonkey, and not in the specifically the Jet Engine (which doesn't execute correctly, but does give a correct error).

Cheers
Steegy

by Pablo » Sun Apr 16, 2006 10:38 pm

Steegy wrote:I would like that MagicNodes can create the "automatic part" of the node (this is <Genre>\<Album Artist>\<Album>) as child of a manually defined (existing or new) parent node (Library\Genre Groups).
The problem is there's no way to access an arbitrary node. The script can easily specify a parent node if there's any way to get a reference to it, such as it does currently with the artist, album, etc, nodes.
It would be nice to be able to access a collection of all the current nodes, whether part of MM core or created by scripts. May be I should this to the scripting wishlist?
Steegy wrote:If you are really sure that the problem is with MediaMonkey or the Jet Engine (and not your script), could you please let the dev's know about this (in case they don't know yet)?
I've tried to just execute a SQL statement with SDB.Database.ExecSQL, resulting in 100% CPU in MM while the statement ran in access completes immediately. That's why I believe it's the JET engine.

In most if not all cases it is possible to rewrite the query so that it runs as fast as in Access. So I believe Access has some built-in protection against redundant code while JET doesn't.

by Steegy » Sun Apr 16, 2006 3:45 pm

Correction to my wish:

Code: Select all

Genre Groups\Rock|filter: Genre LIKE '%Rock%'|icon:genre\<Genre>\<Album Artist>\<Album>
or

Code: Select all

Rock|filter: Genre LIKE '%Rock%'|child of:Library\Genre Groups|icon:genre\Genre Groups\Rock\<Genre>\<Album Artist>\<Album>
I would like that MagicNodes can create the "automatic part" of the node (this is <Genre>\<Album Artist>\<Album>) as child of a manually defined (existing or new) parent node (Library\Genre Groups).

This would be the same as using something like:
"child of:Library\Genre Groups"
or just "child of:Genre Groups"

I would like to be able to let the custom node start from a different (manually specified) parent node than these that are now already possible.


BTW: I've never seen an SQL instruction run in a yoctosecond, but if you have, please let me know... :P
If you are really sure that the problem is with MediaMonkey or the Jet Engine (and not your script), could you please let the dev's know about this (in case they don't know yet)?

Cheers
Steegy

by Pablo » Sun Apr 16, 2006 2:26 pm

Steegy wrote: It would be nice to have the customised tree like:
Library \ Genre Groups \ Rock \ <Genre> \ <Album Artist> \ <Album>
The "Genre Groups" and "Rock" levels would be manually specified like:

Code: Select all

Group Rock|filter: Genre LIKE '%Rock%'|child of:genre|icon:genre\Genre Groups\Rock\<Genre>\<Album Artist>\<Album>
I'm not sure I understand what you propose. Do you want to have the ability to define individual subnodes one by one by using filters?

Steegy wrote: While I'm busy, it would also be nice to be able to use "icon:genre" (like in the example above) or "icon:34" (where 34 is the icon index for the tree icons).
Done. It'll be in the next release.
Steegy wrote: But I would first have to study your long and beautiful script a bit.
The script was becoming a mess, especially the procedure FillCustomNode which is where much of the action happens. I'm trying to clean it up a little bit so it's easier to understand and modify.
Steegy wrote: Even those which run in picoseconds can do that, you know. 8)
Probably even femtoseconds. But I'm still not sure why the Jet engine uses different (poorer) algorithms than Access. Doesn't make much sense to me.
Steegy wrote: Cheers
Cheers!

by Steegy » Sat Apr 15, 2006 5:04 pm

OK, this "simplified" specification works, and I'm now using it as replacement for my auto-playlists (who have been working like this since I started using MM, except for the subnodes of course...):

Code: Select all

Group Rock|filter: Genre LIKE '%Rock%'|child of:genre|icon:top level\<Genre>\<Album Artist>\<Album>
It would be nice to have the customised tree like:
Library \ Genre Groups \ Rock \ <Genre> \ <Album Artist> \ <Album>
The "Genre Groups" and "Rock" levels would be manually specified like:

Code: Select all

Group Rock|filter: Genre LIKE '%Rock%'|child of:genre|icon:genre\Genre Groups\Rock\<Genre>\<Album Artist>\<Album>
While I'm busy, it would also be nice to be able to use "icon:genre" (like in the example above) or "icon:34" (where 34 is the icon index for the tree icons).


These are just some thoughts of course. If I find the time, maybe I'll try to implement these myself, if you (probably) have other work to do. But I would first have to study your long and beautiful script a bit.
SQL queries which run in nanoseconds in Access clog MM.
Even those which run in picoseconds can do that, you know. 8)

Cheers
Steegy

by Pablo » Sat Apr 15, 2006 3:08 pm

Steegy wrote: It's not a special SQL instruction, because MSAccess can do it in some milliseconds.

Does anyone see the problem?
This has happened a few times to me. SQL queries which run in nanoseconds in Access clog MM. It seems for some reason Access interprets the query in a smarter way and has to go over fewer tables (or less times over the same table).

by Pablo » Sat Apr 15, 2006 2:52 pm

If you use a custom field for the groups, then your magic node mask should be:

Code: Select all

Genre by group|child of:genre|icon:bottom level\<group>\<genre>\<album artist>\<album|sort by:max(year)> 
This assumes that you've named the corresponding custom field "group". Otherwise just use the name you gave it.

by Steegy » Sat Apr 15, 2006 12:44 pm

Yeah, could MagicNodes be improved to enable that?

If not, then maybe a custom DB table could be made to place genres in groups, and the use Magic Nodes.

Code: Select all

ID	GenreName           GroupName
-----------------------------------------
1	 Hard Rock           Rock
2	 Psychedelic Rock    Rock
3	 Rock/Pop            Rock
4	 Rock                Rock
5	 Trance              Trance
6	 Progressive Trance  Trance
7	 Melodic Trance      Trance
...
Obviously the SQL query would execute a bit faster if GenreID was used instead of GenreName. But this is just an example... (numbers wouldn't say very much)

Or a custom script could be made, but that seems a lot of useless work, as easier solutions seem to exist.


I thought this would work:

Code: Select all

Group Rock|SQL filter:Songs.IDAlbum IN (SELECT Songs.IDAlbum FROM Songs INNER JOIN Genres ON Songs.Genre = Genres.IDGenre WHERE (Genres.GenreName Like '*Rock*'))|show tracks:no\<Album Artist>\<Album>
But it 100%CPU's MediaMonkey! It's not a special SQL instruction, because MSAccess can do it in some milliseconds.

Does anyone see the problem?

Cheers
Steegy

by Lowlander » Sat Apr 15, 2006 11:28 am

That is true.

by kalex » Sat Apr 15, 2006 11:09 am

But wouldn't playlist just include all the matching files? I'd like to retain a hierarchiv view maybe.

by Lowlander » Sat Apr 15, 2006 9:21 am

Coming back to auto-playlists. They can do that, just say which genre's you want to include.

Of course they would reside in the playlist node instead of the genre node, but would do exactly what you want.

Of course there are many improvement requests for genres including parent - child genre's.

by kalex » Sat Apr 15, 2006 2:31 am

Thanks for the input, everyone!

Well, renaming all my genres is a no-no for me... so maybe I'll go for a custom tag field eventually (about the same amount of work) to achieve that for the moment.

However, I'm dreaming of something much easier. :) Pick a genre/album/artist/compilation/whatever, drag it onto a selfmade super-genre, and drop it there. Something like that. Like the labels in Picasa, to say so.

Would it be technically possible to extend the Magic Nodes script so that it can combine multiple "hits" from one & the same field? Like <genre=dub|genre=lounge|genre=easy-listening> ...I'm hoping I'm not making a total fool out of myself, I have no idea about programming. :D

by Pablo » Fri Apr 14, 2006 6:57 pm

This is the way to do it using MagicNodes (http://www.mediamonkey.com/forum/viewtopic.php?t=3358):

1) Rename all of your genres to "Group-Genre". For example, "Relaxed music-Dub", "Relaxed music-Lounge", "Dance-Techno", etc. This is the tedious part :) .

2) Create a Magic Node with the following mask:

Code: Select all

Genre by group|child of:genre|icon:top level\<genre|left of:->\<genre|right of:->\<album artist>\<album|sort by:max(year)>
(you can replace <album artist> by <artist> if you'd rather use artists than album artists). If you copy and paste, the mask has to fin into one line. Sometimes copying & pasting results in empty lines being pasted, which will make the mask checker complain!

This will allow to browse by groups then specific genres (then artists then albums sorted by year).

by Teknojnky » Fri Apr 14, 2006 6:29 pm

You could probably utilize the 1 of the custom tags & magic nodes or possibly some other script depending on what you want to achieve.

Top