Create Playlist With Songs from Text File

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey for Windows 4.

Moderators: Gurus, Addon Administrators

vbphil
Posts: 29
Joined: Fri Apr 27, 2007 1:03 pm

Create Playlist With Songs from Text File

Post by vbphil »

I'm struggling with how to create a MM Playlist from a vb script. I'm not a complete newbie to MM scripting but haven't figured out all of the MM Automation object scripting techniques.

I'm loading comma delimited song data into a Dictionary object from a text file. The data is; title, artist, album, *mp3 file name.
As in; "A.D. 1928,Styx,Paradise Theatre,P:\Music\A.D. 1928.mp3". The path to the mp3 file is from another PC and is not where it is stored in the MM Library but the file name should be correct.

The text file is created on another PC from an iTunes Genius playlist of songs that were copied from my MM library PC to this iTunes PC. So I know the songs do exists in my MM library.

So, the job of my script is to create a new Playlist in MM from the song names loaded from the text file. How do I create the playlist and then add the song names? I don't need a complete script here just how to create the playlist and then add a song to it from the MM Library given the song title, artist, album and mp3 file name.

Thanks, -phil
Last edited by Lowlander on Fri Sep 21, 2012 11:57 am, edited 1 time in total.
Reason: Moved to correct Forum
Lowlander
Posts: 56630
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Re: Create Playlist With Songs from Text File

Post by Lowlander »

vbphil
Posts: 29
Joined: Fri Apr 27, 2007 1:03 pm

Re: Create Playlist With Songs from Text File

Post by vbphil »

I still haven't discovered how to create a new playlist in MM from script. However, as a workaround to get me going I just create the playlist manually and then run my script to add the tracks.

I'm using ADO to read in the csv file that has the song name, artist and album. ADO works well because some song titles have commas in them and ADO will handle that. I then use the MM SongsDB object's database routines to find the song's ID. With the ID I add the track to the playlist.

Code: Select all

playlist =  curNode.caption
Set oPlaylist = SDB.PlaylistByTitle(playlist)
oPlaylist.AddTrackById(sampleid)
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: Create Playlist With Songs from Text File

Post by trixmoto »

You can create a new playlist like this...

Code: Select all

Set par = SDB.PlaylistByTitle("") 'get the root playlist
Set ply = par.CreateChildPlaylist(tmp) 'where "tmp" is the name of the playlist, "ply" will be the new SDBPlaylist object
If you want to make the playlist a child of a different playlist, instead of the root, this can be done using the same CreateChildPlaylist function.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
vbphil
Posts: 29
Joined: Fri Apr 27, 2007 1:03 pm

Re: Create Playlist With Songs from Text File

Post by vbphil »

that's perfect thanks!!
I had played around with CreateChildPlaylist and saw how that worked but never realized how to get to the root.

Thanks again, question answered.

-phil
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: Create Playlist With Songs from Text File

Post by trixmoto »

Glad I could help :)
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Post Reply