Created
June 28, 2014 11:14
-
-
Save eramdam/92d648c67e2cd5c499eb to your computer and use it in GitHub Desktop.
A little nodeJS script (clipboard works only on OSX) to fetch tags about an artist from Last.FM quickly
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
var request = require('request') | |
var clipboard = require('child_process').spawn('pbcopy') | |
var colors = require('colors') | |
var log = console.log | |
function getTags(artistName) { | |
request('http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist='+artistName+'&api_key=21c55ae94ac46850ab59171f7da02c1d&format=json', function(err, res, body) { | |
if(!err && res.statusCode == 200) { | |
var json = JSON.parse(body) | |
var toCopy = [] | |
json.artist.tags.tag.forEach(function(tag) { | |
toCopy.push(tag.name) | |
}) | |
toCopy.push(json.artist.bio.placeformed) | |
clipboard.stdin.write(toCopy.join(', ')) | |
clipboard.stdin.end() | |
console.log('✔ '.green+'Copied "'+toCopy.join(', ')+'" to clipboard') | |
} | |
}) | |
} | |
getTags(process.argv[2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment