Skip to content

Commit

Permalink
Added play count
Browse files Browse the repository at this point in the history
  • Loading branch information
Namasteh committed Aug 16, 2014
1 parent 6998a7b commit 64a1cab
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/plugins/last_fm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,19 @@ def nowPlaying(m)
artist = rTracks[0]['artist']['#text']
track = rTracks[0]['name']
album = rTracks[0]['album']['#text']
trackURL = rTracks[0]['url']

trackURL = trackURL.gsub('\\', '')

# If we send the username with the track.getInfo request we get additional info such as userLoved
# we have to URI.encode because of tracks with special characters and spaces
trackInfo = JSON.parse(open(URI.encode("#{BaseURL}?method=track.getInfo&username=#{userName}&artist=#{artist}&track=#{track}&api_key=#{key}&format=json")).read)

loved = ":("
if (trackInfo['track']['userloved'] == "1")
loved = "4<3"
end

m.reply "#{m.user.nick} - Track: \"4#{track}\" | Artist: 7#{artist} | Album: \"10#{album}\" | Loved #{loved} | Listen to this now: #{trackURL}"
uPlays = trackInfo['track']['userplaycount']

m.reply "#{m.user.nick} - Track: \"4#{track}\" | Artist: 7#{artist} | Album: \"10#{album}\" | Loved #{loved} | Plays: #{uPlays} "
end

def reload
Expand Down

0 comments on commit 64a1cab

Please sign in to comment.