Mending the Relationship Between iTunes and M3U

iTunes handles .m3u playlists in a way that has been found wanting by many advocates of streaming music. You see, iTunes thinks you would like to add the contents of an m3u playlist into your library in the same way that you add actual mp3 files. This works fine if the m3u contains only a single reference to some Internet radio stations continuous stream, but it fails quite spectacularly when the playlist actually contains a number of items, all of which will be streamed individually. MyTunesRSS, Jinzora and essentially every other personal remote music streaming solution uses m3u playlists in this way.

So, after discovering this problem in iTunes I quickly found a solution. Some kind soul out there had written a nice little piece of Applescript to fix this problem by generating a new user playlist in iTunes and adding the m3u entries to it. And some even kinder soul had wrapped this Applescript up into a nice little .app which can be associated with all .m3u files and does all this magic, well, automagically.

But then MacWorld happened.

So, it seems that the iTunes 7.6 update has broken this functionality. The code now throws the error:

Can’t get item 1 of {alias “Macintosh HD:Users:username:Desktop:playlist.m3u”}.

I am a total Applescript n00b so I cannot immediately find out what is wrong, so I’m posting this so that perhaps some Internet traveler will stumble upon it and, having the same problem as I, quickly find the proper solution. Everyone else posting about this issue apparently stopped blogging some time in 2006.

Here is the offending code:

on open m3uFileList
	tell application "iTunes"
		activate
		set newPlaylist to make new user playlist
		set name of newPlaylist to (current date) as string
		repeat with m3uFile in m3uFileList
			add m3uFile to newPlaylist
		end repeat
		play newPlaylist
	end tell
end open

6 Responses to “Mending the Relationship Between iTunes and M3U”

  1. January 22nd, 2008 | 10:53 am
  2. onotob
    January 22nd, 2008 | 11:46 am

    I’m sure that works perfectly if your iTunes isn’t broken. :(

  3. January 22nd, 2008 | 11:01 pm

    yes. yes it does :)

  4. January 23rd, 2008 | 8:15 am

    Now I remember why it took me so long to adopt iTunes.

  5. January 26th, 2008 | 6:08 pm
  6. Hugh
    February 28th, 2008 | 5:54 am

    I hit the same issue with my existing m2u-to-itunes applescript… and boy did it take some diagnosis…
    Looks like the latest iTunes update has fixed it anyway, but the root cause seems to have been an “extended file attribute” -

    I found a commandline util called xattr which let me read/change/delete them and found that the m3u file (downloaded) had an attrib named com.apple.FinderInfo which it seems that release of itunes would refuse to allow as a valid file for import.
    Calling xattr to delete the attrib before the import fixed it. It’s now no longer required.

    Interesting/frustrating/random or what!?

    H
    Here’s my whole m3u-to-iTunes script anyway:

    on open m3uFileList
    tell application “iTunes”
    activate
    if minimized of browser window 1 then
    –display dialog “iTunes was mini”
    set minimized of browser window 1 to false
    end if
    set newPlaylist to make new user playlist
    set name of newPlaylist to do shell script “date +%Y-%m-%d\\ %H:%M:%S”
    repeat with m3uFile in m3uFileList
    –display dialog “trying to load ” & m3uFile & ” from list: ” & m3uFileList
    set f to POSIX path of m3uFile
    –display dialog “Running xattr on ” & f
    –do shell script “/usr/local/bin/xattr -d com.apple.FinderInfo ” & quoted form of f
    add m3uFile to newPlaylist
    tell application “Finder”
    delete file m3uFile
    end tell
    end repeat
    set the view of browser window 1 to newPlaylist
    play newPlaylist
    set minimized of browser window 1 to true
    end tell
    end open

Leave a reply