list of Albums/Artists

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

AlanB

list of Albums/Artists

Post by AlanB »

First of all...
Thanks to Lowlander for redirecting me to the scripts forum and his repository of scripts.
Thanks also to Hixbb for his primer in MsAccess Visual Basic, which gave me enough of a primer to get this job done.

What I wanted was a way of obtaining a list of Artists and Albums.

Looking through Lowlanders scripts, I came to the conclusion that this was not practical using a script (I am welcome to be proved wrong if someone knows better). In addition, this would require MM Gold.

So, having worked with Access some 10 years ago, I though I would try that approach. Well, it immediately obvious that although there are Artist and Album tables, there is no enforced relationship between them. So having seen Hixbb's Visual Basic code, I thought that I would try that approach. Well, it gave me the starters that I needed.

Maybe there is a more elegant query that I could have used, but this combination works for me.. a but of query and a bit of code.

This is the code, the comments tell you everything? that you need to do to apply it to the MediaMonkey Access database (might be a good idea to backup the database before you start). Users will probably want to change the directory/filename for the print file.


Option Compare Database

Option Explicit

'Open MediaMonkey database in Access (backup your database!)
'Create a new module (Module1).
'In Viausl Basic you will need this code.
'In Visual Basic, ensure that Tools...References..."Microsoft DAO 3.6 Oject Library" is checked

Function CreateAlbumAndAlbumArtistList()

Dim dbs As DAO.Database
Set dbs = CurrentDb

Dim ArtistsSQL As String
ArtistsSQL = "SELECT * FROM Artists ORDER BY Artist"

Dim Artists As DAO.Recordset
Set Artists = dbs.OpenRecordset(ArtistsSQL)


Open "c:\MediaMonkey\AlbumAndAlbumArtistList.txt" For Output As #1
If Not Artists.EOF Then
Do Until Artists.EOF
Dim AlbumSQL As String
AlbumSQL = "SELECT * FROM Albums WHERE IDArtist = " + Str(Artists!ID)
Dim Albums As DAO.Recordset
Set Albums = CurrentDb.OpenRecordset(AlbumSQL)
If Not Albums.EOF Then
Do Until Albums.EOF
Debug.Print Artists!Artist; Tab(30); " = "; Albums!Album
Print #1, Artists!Artist; Tab(30); " = "; Albums!Album
Albums.MoveNext
Loop
End If
Artists.MoveNext
Loop
End If
Close #1
End Function


Any recommendations for improvements are gatefully accepted.

Alan
roylayer
Posts: 85
Joined: Tue Feb 25, 2003 12:44 am

Post by roylayer »

That looks good. For those people who don't want to do any coding in Access, you could probably create a query in Design view and base a Report on it to do the same thing and perhaps give you more options in formatting.
Happy user of MediaMonkey Gold version 2.5.5.998
Computer: p4, 2.5 ghz, 3 gb ram, win xp
jaxjon
Posts: 102
Joined: Tue May 27, 2003 8:47 am
Location: Florida USA

Post by jaxjon »

AlanB

What do I save your script as, and do I have to run through MM or standalone?

Jon
AlanB

Post by AlanB »

My script is for Microsoft Access.
The comments in the start of the code should tell you what you need to know...
Open the MediaMonkey.mdb in Access.
Create a new module and insert the code into it.
If you leave the edit cursor within the function when you hit the run button, it will know which function you want to run.

Have you looked at the "Export Artist-Album List to HTML" thread from Frodo56us. He is looking at the same problem as a VB script for MM. If it works, it should be a better solution (with HTML output). So keep an eye on that as well.

AlanB
jaxjon
Posts: 102
Joined: Tue May 27, 2003 8:47 am
Location: Florida USA

Post by jaxjon »

AlanB

Thanks for the quick reply.

What I am looking for is a way to build a script to access the a specific genre field of the database, get a list of songs that fit that genre and then play in MM or Winamp those songs (realising that I can already do this manually through playlists or nodes). I have edited a script and made it access the current songlist and play those songs, but I want to access the entire database (not just what is selected or visible in MM)and I also cannot figure out how to just get a specific genre of songs.

The object of my obsession is to eventually build a virtual radio station through mediamonkey and play specific songs at specific times on specific days.

I thought your code might help to move me in the right direction.
I am new to scripting, though I have some experience coding PAL scripts for SAM2 broadcaster and some Java.

Thanks

Jon
AlanB

Post by AlanB »

Well, I am new to this too, so I certainly don't know the answers.

But for what it is worth, I would not suggest the Microsoft Access script as a means to what you are trying to do. Mine was for a simple interrogation function (i.e. it did not attempt to modify the database). Access gives access to some much more powerful interrogation methods, but in contrast you need to know much more about how MM handles the database, especially if you were to risk making changes to the database!

A VB script for MM would be safer.

Lowlanders HTML export script examples. It shows that
Set list = SDB.AllVisibleSongList
is quite a good way of getting at the database. OK,you still need to be at one of the top level nodes such as Albums or Artists so that all the songs are visible for it to work, but this gives the opportunity to apply a sort order.
You could then iterate all songs (as in Lowlandrs examples) but rather than naming and formatting as HTML, you could name and format as a playlist, exporting them to appropriate files based on the .Genre. You could ask the user for the Genre to export first, or use the Genre field to determine the name of the file to send the song to (i.e. openning, appending and closing file on a song basis to extract all genres simultaneously). The songs' filename (.Path) could readily be formatted and exported to a file in playlist format which MM's file monitor would re-import.

No answers... just ideas, hope this is some helps.

AlanB
Turin Brakes
Posts: 4
Joined: Wed Jun 16, 2004 4:55 am
Location: Good old Germany
Contact:

Post by Turin Brakes »

Hi,

how do you like my script in
http://www.songs-db.com/forum/viewtopic.php?t=1588 ?

HTH
Post Reply