Skip to content

Instantly share code, notes, and snippets.

@eramdam
Created June 28, 2014 11:14
Show Gist options
  • Save eramdam/92d648c67e2cd5c499eb to your computer and use it in GitHub Desktop.
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
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