Skip to content

Instantly share code, notes, and snippets.

@thisfred
Created November 2, 2008 16:51
Show Gist options
  • Save thisfred/21719 to your computer and use it in GitHub Desktop.
Save thisfred/21719 to your computer and use it in GitHub Desktop.
CmdUtils.CreateCommand({
name: "lastfm",
icon: "http://cdn.last.fm/flatness/favicon.2.ico",
// homepage: "http://thisfred.blogspot.com/",
author: { name: "eric casteleijn", email: "thisfred@gmail.com"},
license: "GPL",
description: "Looks up artists or tracks on last.fm",
takes: {"input": noun_arb_text},
preview: function( pblock, input ) {
var msg = 'Looks up "${inputText}" on lastfm.';
var subs = {inputText: input.text};
pblock.innerHTML = CmdUtils.renderTemplate( msg, subs );
},
execute: function(input) {
arr = input.text.split(' - ');
url = 'http://www.last.fm/music/' + arr[0];
if (arr.length > 1) {
url = url + '/_/' + arr[1];
}
url = url.replace(' ', '+', 'g');
Utils.openUrlInBrowser(url)
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment