Jump to content
IGNORED

Applescript to convert iTunes playlist to m3u playlist


ldolse

Recommended Posts

I use iTunes to organize my library, but I use other sofware (MPD in my case) to actually play music. Many programs support m3u playlists, but iTunes doesn't export them. The introduction of the Genius feature on top of smartplaylists made this sort of functionality highly desirable, at least for me. Google turned up lots of requests for this type of export, but there weren't any solutions out there, so I hacked together this script.

 

Download it here (linked).

 

Caveats/Requirements:

  • This is Applescript, so it only works on OS X
  • In order for the script to be of any use your iTunes media folder location must be the same directory as your third party software's root music directory
  • whatever software you're using must support relative(to music root) links to the files rather than absolute(full path) links.
  • The drive with your third party software's playlist folder should also be mounted to OS X. (If it's not you can save it anywhere and move it after the fact.)

-

 

To install:[*]Unzip the file archive[*](on OSX) Move it to /Users/[profilename]/Library/iTunes/Scripts (create the Scripts folder if it doesn't exist)[*]Start/Restart iTunes

-

 

 

To Use it:[*]Highlight the tracks you want exported to a m3u (typically just view whatever playlist you want and hit Command-A)

[*]Click the Script Icon on the Menu Bar beside 'Help', then select 'Export MPD m3u'[*]Change the playlist name if desired, then specify your playlist folder when asked

[*](optional) Edit the script in the Applescript Editor to change the default location to avoid specifying the playlist folder every time.

 

 

So far I've only tested with MPD, but I don't see why this wouldn't work with other apps like Foobar, Winamp, etc.

It works great with the regular Genius feature, smartplaylists, etc. If you also want to use it with Genius Mixes then grab this script as well:

http://dougscripts.com/itunes/scripts/ss.php?sp=dumbdowngeniusmix

Use that to create a regular playlist from a Genius Mix, then convert that playlist to m3u using my script.

 

I also have to give credit to dougscripts.com as a source for several of the techniques I used to create the script.

 

Side note - Chris, if you happen to read this, the css code for your ordered/unordered lists seems to be a bit a bit funky - too much spacing at the top, too little at the bottom....

 

 

mpdPup maintainer

Link to comment

Not sure what you're looking at in the iTunes menu. I don't see anything in the file menu except 'export playlist', which doesn't export an m3u file, just a ton of details on each track.

 

It may be that Songbird is capable of importing this default iTunes export, but it's not widely compatible. M3U is pretty much universal.

 

 

mpdPup maintainer

Link to comment

Select a playlist in iTunes. Then right-click (control-click) on the selected playlist, and a contextual menu appears with an "Export.." option. You go to that, and it gives you several options including ascii text output, unicode text output, xml output, m3u output and m3u8 output. (I had no idea what these last two were, and did this, by weird coincidence, for the first time ever this morning. I just went down the list until I found a format that Songbird would accept.)

 

I know from painful experience how hard it is to work with Applescript (I've written a bunch of osascript/shellscript hybrids), so I in no way want to detract from what you have done. Apple does a good job of hiding some of the more useful features.

 

I was wrong about it being in the File menu. Sorry. Faulty memory.

 

Link to comment

That's good to know about that feature. Apple did a good job of hiding it - the original google searches I made didn't turn it up (and still don't, though I see some other possible solutions now).

 

That said, my script is still useful, as Apple's m3u exports use absolute file names. Absolute files only work if the m3u file is used on the exact same system it was created on, so it's a no go for mpd or Windows based software. If you're using the playlist from different systems you need relative paths, which is what my script creates.

 

So if you need absolute links, use Apple's built-in export. If you need relative links, grab my script.

 

 

Speaking of Windows, I'm not entirely sure my script will work correctly with windows programs because it uses forward slashes. I can create a Windows oriented version if someone needs it.

 

 

mpdPup maintainer

Link to comment

Yeah, I just saw that one on a recent search as well. Not sure why I didn't find it when I originally wrote this script (which was six or seven months back). It might be that everything I tested back then used absolute links, not sure. All I remember is I did a lot of searching at the time and couldn't find anything that did exactly what I needed, which was properly integrate with my mpd system.

 

 

mpdPup maintainer

Link to comment

Again, thanks for writing this.

 

I apologize for the distraction, but it sounds as if I might have found something hidden and useful by poking around. It may be a recent feature (which would also account, maybe, for the lack of documentation).

 

You might want to submit this to MacOSX Hints, so it can get wider distribution. I'm sure you will be doing the community a favor (and you will have lots of geeks offering "improvements").

 

I know there is a way to go from unix directory hierarchy to the old-style Mac OS hierarchy in applescript, but I don't know if there is a way to do Windoze elegantly. If it were me, I would just make a system call to perl to do an in-line edit, to change the forward to back slash. I don't know what else you have to do to make it Windoze-compliant, because I never use that OS.

 

The ability to generate relative paths is definitely a major plus, one which I didn't appreciate simply because I wanted my playlist to access the same music files as itunes in the exact same location. I would think relative paths is more general and should always work, so no need for your applicability disclaimer.

 

Anyway, definitely submit this to Mac OS X hints: http://www.macosxhints.com/

It is the first site I would go to, to look for this. Please feel free to add the information about the contextual menu thingie for exporting playlists too.

 

Link to comment

No distraction at all. Switching this to Windoze paths is actually trivial. By default Applescript returns directories with ':' between the directories instead of the Posix '/'. At the time I didn't know there was a function to switch the path to Posix automatically, so I wrote the inline edit function you described. Anyone with the wherewithal to edit it just needs to find that function and replace '/' with ''...

 

I can submit to MacOSXhints, though you're welcome to as well, I don't currently have an account, and the built in feature you've 'discovered' has the same merit as the script for many users.

 

 

mpdPup maintainer

Link to comment
  • 11 months later...

While iTunes will export and m3u playlist, I have a particular hiccup in my system that I can't seem to solve. This may be a solution, however the directory structure you wrote for sounds like won't work with my setup. I'll describe my setup and issues:

 

Music is stored in ALAC (Apple Lossless) in an iTunes Media directory on my HP 895 MSS. I also have the Squeezecentre plugin on the MSS and it points to the Itunes Media Folder/Music as the source for music.

 

Front end, playback is via a Squeezebox Touch connected to the home network via gigabit ethernet.

 

I have tried exporting playlists from iTunes in m3u format to the playlist folder on the MSS, however they will not play when accessed by the Touch. All playlists show up as empty.

 

I have opened the playlist files in MS Word, edited the slashes to match the format that they appear in a playlist that is built within the Squeezecentre plugin GUI (when built manually in Squeezecentre the playlists will play on the Touch, btw). I also tried to match the directory syntax using the edit features, then resave as an m3u text file. The resulting playlist will not play on the SqueezeBox Touch.

 

So, I am either screwing up syntax, missing something in the directory structure, etc.

 

However, I have about 50 playlists, both home built and done in Genius, that I would like to have accessible via the Touch.

 

Has anyone tried your script with an MSS and SB Touch?

 

Maybe too detailed a question.

 

ALso, I have posted queries on the Squeezecenter forums and HP Mediasmart forums, and while I haven't looked back on them in some time, no one was able to solve my issues over a period of months early last year.

 

Any suggestions, or should I make a separate thread?

 

 

Link to comment

I'm not sure what a HP 895 MSS is, but I guess that means you're running on Windows. This script requires Applescript, which only runs on a Mac.

 

If you are using a Mac it should be pretty easy to tweak the script for your requirements, but I don't understand based on your description what changes are required.

 

 

mpdPup maintainer

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...