dionidium.com

Wayne Burkett's Weblog | Home

Greasemonkey M3U Generator
01:16PM CST June 07, 2005 | Comments [8]

I love this M3U generator bookmarklet that Andy Baio pointed to a couple days ago, but I'd like to know whether the page I'm viewing links to any MP3s before I click. Playlist is a Greasemonkey user script that does exactly what Hublog's bookmarklet does, but notifies the user that a playlist has been generated with an icon in the top right corner of any page linking to MP3s.

Here's what it looks like on Music for Robots.

#1 | 01:34AM UTC July 03, 2005 | strayan
strayan
Why doesn't this script understand spaces? e.g. When I click the button it'll enqueue in Winamp but it'll only play an mp3 that's named like so (i.e. no spaces): "hello_world_-_this_is_god.mp3" It won't play an mp3 with spaces such as: "hello world - this is god.mp3" Is there a fix for this?
#2 | 08:05PM UTC August 20, 2005 | nobody
nobody
Would it be difficult to remove the duplicates, like when used on a Webjay playlist ?
#3 | 07:16PM UTC August 31, 2005 | The Amigo
The Amigo
I was able to make it work with spaces by chainging the this line:

if (href.match(/\.mp3$/)) { links.push(href); }

to this:

if (href.match(/\.mp3$/)) { links.push(href.replace(/%20/g, "%2520")); }

I haven't tested any other special chars so it's probably not perfect, but at least it works for spaces.
#4 | 11:23AM UTC September 05, 2005 | Tim
Tim

I haven't tried this, but if the above trick works then the general case should be:

if (href.match(/\.mp3$/)) { links.push(escape(href)); }
#5 | 04:27PM UTC September 06, 2005 | Lee Azzarello
Lee Azzarello

Appending this code to line 41 will include ogg/vorbis files, although there's probably a better way to do this with some kind of OR statement for the contains() xpath function on line 32.

xpath = '//a[contains(@href, "ogg")]'; var oggs = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); for (i = 0; i < oggs.snapshotLength; i += 1) { href = oggs.snapshotItem(i).href; if (href.match(/\.ogg$/)) { links.push(href); } }
#6 | 08:50AM UTC September 13, 2005 | alf
alf
If you want to remove duplicates, get correct filenames, pick up media types other than mp3 and create playlists in different formats, try the bookmarklets provided by Playr.
#7 | 08:49AM UTC October 22, 2005 | Wayne
Wayne

So, the bookmarklets are great, alf -- wouldn't have thought of this on my own. But suggesting them sort of misses the point. The Greasemonkey script is automatic. I keep seeing that little icon in the top right and thinking, "cool, there's audio here." And that's miles from thinking, "I wonder if there's audio here" and then clicking the bookmarklet on every one of the 50 kazillion pages I view every day, only to find out that, you know, on most there isn't.

Some smart folks call this manufactured serendipity. And I think it rocks.

#8 | 12:28AM UTC October 08, 2006 | strayan
strayan
Has anyone managed to get the playlist userscript working with iTunes? And how?

Keep up with new comments to this entry by subscribing to its Atom feed.


Comments must be well-formed and contain valid markup. Allowed elements: em strong code cite abbr acronym a ul ol p blockquote. Spam will be deleted immediately. Line breaks are not automatically converted. Your name is required. Your e-mail address will be kept private.