Tutorial to MediaMonkey, anyone?

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: Tutorial to MediaMonkey, anyone?

by trixmoto » Wed Sep 13, 2006 3:15 am

Yes, my solution is not ideal as you then need to do a QuerySongs using each ID to get each song, which is obviously slower. I was not offended by your comments, SQL is not my strong point. Bex's solution is the best, he's an SQL guru! :)

by almo9004 » Tue Sep 12, 2006 2:31 pm

@ Bex:
Yey, your suggestion worked and it was a quite simple solution, even if most of it is greek to me. :D

@ Trixmoto:
I hope I didn't hurt you with my unsensitive behaviour and possible assault. :oops:
I'm working on your suggestion, but I seem to run into some problems. As far as I know, it returns an SDBDBIterator from which you can extract the (record) index of the song.
But how do I turn the numbers into songs? :)

Thank you all for your responds, you have helped me greatly! :D

by Bex » Tue Sep 12, 2006 11:40 am

First of all. Trixi is a pro! Bigtime!

This also works if you must use SDB.Database.QuerySongs:

Code: Select all

SDB.Database.QuerySongs("AND Genre in (Select IDGenre From Genres Where GenreName  = 'Pop')")
But is a bit slower than "= 13" due to the inline.

/Bex

by trixmoto » Tue Sep 12, 2006 10:54 am

Actually I think Pop is always 13 so you could try...

Code: Select all

SDB.Database.QuerySongs("AND Genre=13")

by trixmoto » Tue Sep 12, 2006 10:51 am

Oh yes, to reference GenreName you need to do a JOIN with the Genre table but you can't do that in the WHERE statement. You might need to do an OpenSql with...

Code: Select all

SELECT Songs.ID FROM Genres INNER JOIN Songs ON Genres.IDGenre = Songs.Genre WHERE Genres.GenreName LIKE 'Pop'
Hopefully someone has a way for you to do it with the QuerySongs if this is not helpful to you.

by almo9004 » Tue Sep 12, 2006 9:03 am

@ trixmoto:
Sorry man, it doesn't work.
I'm getting the exact same error as before. :x :cry:

I think we are gonna need some serious help from the pros... :wink: :)

by trixmoto » Mon Sep 11, 2006 5:10 am

Try

Code: Select all

AND Genres.GenreName LIKE 'Pop'

by almo9004 » Mon Sep 11, 2006 4:39 am

Hey, guys!

Thanks for your answers, they really cleared up the sky :lol: :P
Except for one thing, when I tried QuerySongs("AND Genres.GenreName = 'Pop'") I got an errormessage saying (translated into English)

Code: Select all

There was a problem querying the database:
07002:[Microsoft][Driver for ODBC Microsoft Access] Too few parameters given. 1 was expected.
The lines looks like:

Code: Select all

...
strSQL = "AND Genres.GenreName = 'Pop'"
set iter_songs = SDB.Database.QuerySongs(strSQL) '<- Error points here
...
PS. I will have a look at MagicNodes, see if there is any help. But that doesn't stop you from answering. :)

PPS. Remember to honor the victims of 9/11 today at 13:46 GMT.

by DiddeLeeDoo » Sun Sep 10, 2006 11:36 am

Just a quick non-script solution.
New Auto Playlist - Advanced - Genre=Rock, Max Tracks 30
New Auto Playlist - Advanced - Genre=Techno, Max Tracks 40
New Auto Playlist - Advanced - Genre=Classical, Max Tracks 30

Combine and stirr..

QuerySongs is good for things like this by the way.

by trixmoto » Sun Sep 10, 2006 7:59 am

My knowledge is more VBScript and less SQL so I'll try to fill in the blanks!

1. The differences are...
- QuerySongs returns a SongIterator which is a list of songs for you to iterate through. The query is also only the WHERE part of the statement so should begin with "AND".
- OpenSQL returns a DBIterator which is a results set containing the information you have requested, which you can then iterate through. This should be the full SQL statement.
- ExecSQL doesn't return anything. It is used to perform UPDATE functions primarily and it's not something I've ever needed to use.

3. I use DevGuru for a lot of my SQL syntax, and also tend to ask people here as there are some real experts amongst us (of which I'm not one!)

4. It is possible, but would be extremely slow. The only feasible solution is with SQL.

by Bex » Sun Sep 10, 2006 6:24 am

I dont know VBScript but so I can't answer all questions.

2. There are no fieldname called Genre in table Genres. The correct syntax is:
QuerySongs("AND Genres.GenreName = 'Pop'")
Which would work just fine.

3. Well, to learn everything will take a while. Try to google "sql tutorial".
(This is pretty good: http://www.w3schools.com/sql/sql_intro.asp )
The SQL syntax differs between different databases. But is the same to 95%. MM uses MS Access as its database.
Tip!
Skip everything that has todo with altering data like Update, Delete, Insert into. Also skip everything that has todo with "SQL Data Definition Language (DDL)". At this stage you only want to query the database and "look" at the data.

4. I dont think so

/Bex

by almo9004 » Sun Sep 10, 2006 4:57 am

Hi, I'm back.

My Internet connection has been offline for a few days, sorry for making you wait.

I've come to realize that if i'm gonna be able to accomplish a script that creates playlists with say, 30% rock, 40% techno and 30% classical (as mentioned), i will have to know SQL. So, i started searching and observing scipts with even the tiniest line of SQL and came up with that some people use QuerySongs() and some openSQL() or even execSQL. So now, my questions:

1. Which should I use, QuerySongs(), openSQL or execSQL()?

2. Why does the line QuerySongs("AND Artists.Artist = 'Beatles'") work and QuerySongs("AND Genres.Genre = 'Pop'") does not?!

3. Where can I learn EVERYTHING about SQL in MediaMonkey?

4. Can I accomplish my above mentioned script without SQL?

Hope I'm not too nooby... :P :)

by almo9004 » Sun Sep 03, 2006 4:27 am

:D :lol: :D roving cowboy, i guess that's a way to do it... :D

OK, I'm gonna have myself a good look at your scripts, guys, and hopefully I will get a few steps closer to realizing my ideas in my last post.

Undoubtedly, I will have lots of questions when I'm done studying your works, so stay tuned!

Thanks!

by rovingcowboy » Sat Sep 02, 2006 1:13 pm

i do the simple thing.

i just ask for scripts and let this other great scripters do them since i have not figured out vbs and am really unsure if i ever will.

so i let the best ones do the scripting.

8)

by paulmt » Fri Sep 01, 2006 3:11 pm

I have been using MM for about a year and in the last couple of months have really started to get interested in customising my MM.
I am attempting to teach my self VBScript as well as skinning.
I avoid jumping into the forum and asking for help every time I hit "the wall" simply because I feel I learn better by working it through myself.

There is plenty of resource available on VBScript on the net, as well as there is a host of help within this forum.

The best way though, I find is to de-construct some of the great scripts already written and used in MM <gulp, sorry> pull them apart line by line and look at what has been done there. I then try different things to see if what I had thought works. By using the fine work already done here it is teaching me an enormous amount.

In time I know I will be contributing my own twists on how I think MM can be used. Honestly I really don't think you can be spoon fed this, via a tutorial, you have to do the hours sitting in front of the computer nutting the problems through.

So, although all help is appreciated, it is already very available if you look.

Top