Created
November 2, 2008 16:51
-
-
Save thisfred/21719 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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