Skip to content

Instantly share code, notes, and snippets.

@BenWard
Created November 25, 2010 02:10
Show Gist options
  • Save BenWard/714796 to your computer and use it in GitHub Desktop.
Save BenWard/714796 to your computer and use it in GitHub Desktop.
Convert a Spotify URL into a MOG URL for music playback in North America.
javascript:(function()%20{function%20esc(s)%20{return%20s.replace(%27%20%27,%20%27-%27);}var%20track,%20artist,%20album,links%20=%20document.getElementsByTagName(%27a%27);for(var%20i=0;l=links[i];i++)%20{if(l.href.match(/^spotify:track:/))%20{track%20=%20l.innerText;}else%20if(l.href.match(/open.spotify.com\/artist/))%20{artist%20=%20l.title;}else%20if(l.href.match(/open.spotify.com\/album/))%20{album%20=%20l.title;}}window.location.href%20=%20%27http://mog.com/music/%27%20+%20esc(artist)%20+%20%27/%27%20+%20esc(album)%20+%20%27/%27%20+%20esc(track);return%20true;})();
(function() {
function esc(s) {
return s.replace(' ', '-');
}
var track, artist, album,
links = document.getElementsByTagName('a');
for(var i=0;l=links[i];i++) {
if(l.href.match(/^spotify:track:/)) {
track = l.innerText;
}
else if(l.href.match(/open.spotify.com\/artist/)) {
artist = l.title;
}
else if(l.href.match(/open.spotify.com\/album/)) {
album = l.title;
}
}
window.location.href = 'http://mog.com/music/' + esc(artist) + '/' + esc(album) + '/' + esc(track);
return true;
})();
@BenWard
Copy link
Author

BenWard commented Nov 25, 2010

Superseded by MOGthis, a combined bookmarklet that redirects from Rdio and Spotify URLs to MOG. https://gist.github.com/714812

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment