4 # :title: lastfm plugin for rbot
6 # Author:: Jeremy Voorhis
7 # Author:: Giuseppe "Oblomov" Bilotta <giuseppe.bilotta@gmail.com>
8 # Author:: Casey Link <unnamedrambler@gmail.com>
9 # Author:: Raine Virta <rane@kapsi.fi>
11 # Copyright:: (C) 2005 Jeremy Voorhis
12 # Copyright:: (C) 2007 Giuseppe Bilotta
13 # Copyright:: (C) 2008 Casey Link
14 # Copyright:: (C) 2009 Raine Virta
18 require 'rexml/document'
25 @location = hash[:location]
26 @description = hash[:description]
27 @attendance = hash[:attendance]
29 @artists = hash[:artists]
31 if @artists.length > 10 #more than 10 artists and it floods
32 diff = @artists.length - 10
33 @artist_string = Bold + @artists[0..10].join(', ') + Bold
34 @artist_string << _(" and %{n} more...") % {:n => diff}
36 @artist_string = Bold + @artists.join(', ') + Bold
41 unless @attendance.zero?
42 return "%s %s @ %s (%s attending) %s" % [@date.strftime("%a, %b %d"), @artist_string, @location, @attendance, @url]
44 return "%s %s @ %s %s" % [@date.strftime("%a, %b %d"), @artist_string, @location, @url]
46 alias :to_s :compact_display
50 define_structure :LastFmVenue, :id, :city, :street, :postal, :country, :name, :url, :lat, :long
52 class LastFmPlugin < Plugin
54 Config.register Config::IntegerValue.new('lastfm.max_events',
55 :default => 25, :validate => Proc.new{|v| v > 1},
56 :desc => "Maximum number of events to display.")
57 Config.register Config::IntegerValue.new('lastfm.default_events',
58 :default => 3, :validate => Proc.new{|v| v > 1},
59 :desc => "Default number of events to display.")
60 Config.register Config::IntegerValue.new('lastfm.max_shouts',
61 :default => 5, :validate => Proc.new{|v| v > 1},
62 :desc => "Maximum number of user shouts to display.")
63 Config.register Config::IntegerValue.new('lastfm.default_shouts',
64 :default => 3, :validate => Proc.new{|v| v > 1},
65 :desc => "Default number of user shouts to display.")
66 Config.register Config::IntegerValue.new('lastfm.max_user_data',
67 :default => 25, :validate => Proc.new{|v| v > 1},
68 :desc => "Maximum number of user data entries (except events and shouts) to display.")
69 Config.register Config::IntegerValue.new('lastfm.default_user_data',
70 :default => 10, :validate => Proc.new{|v| v > 1},
71 :desc => "Default number of user data entries (except events and shouts) to display.")
73 APIKEY = "b25b959554ed76058ac220b7b2e0a026"
74 APIURL = "http://ws.audioscrobbler.com/2.0/?api_key=#{APIKEY}&"
88 def help(plugin, topic="")
89 period = _(", where <period> can be one of: 3|6|12 months, a year")
90 case (topic.intern rescue nil)
92 _("lastfm [<num>] events in <location> => show information on events in or near <location>. lastfm [<num>] events by <artist/group> => show information on events by <artist/group>. The number of events <num> that can be displayed is optional, defaults to %{d} and cannot be higher than %{m}") % {:d => @bot.config['lastfm.default_events'], :m => @bot.config['lastfm.max_events']}
94 _("lastfm artist <name> => show information on artist <name> from last.fm")
96 _("lastfm album <name> => show information on album <name> from last.fm [not implemented yet]")
98 _("lastfm track <name> => search tracks matching <name> on last.fm")
100 _("lastfm now [<nick>] => show the now playing track from last.fm. np [<nick>] does the same.")
102 _("lastfm set user <user> => associate your current irc nick with a last.fm user. lastfm set verb <present>, <past> => set your preferred now playing/just played verbs. default \"is listening to\" and \"listened to\".")
104 _("lastfm who [<nick>] => show who <nick> is on last.fm. if <nick> is empty, show who you are on lastfm.")
106 _("lastfm compare [<nick1>] <nick2> => show musical taste compatibility between nick1 (or user if omitted) and nick2")
108 _("lastfm shouts [<nick>] => show shouts to <nick>")
110 _("lastfm friends [<nick>] => show <nick>'s friends")
111 when :neighbors, :neighbours
112 _("lastfm neighbors [<nick>] => show people who share similar musical taste as <nick>")
114 _("lastfm loved[tracks] [<nick>] => show tracks that <nick> has loved")
115 when :recenttracks, :recentracks
116 _("lastfm recent[tracks] [<nick>] => show tracks that <nick> has recently played")
118 _("lastfm topalbums [<nick>] [over <period>] => show <nick>'s top albums%{p}") % { :p => period }
120 _("lastfm topartists [<nick>] [over <period>] => show <nick>'s top artists%{p}") % { :p => period }
122 _("lastfm toptracks [<nick>] [over <period>] => show <nick>'s top tracks%{p}") % { :p => period }
123 when :weeklyalbumchart
124 _("lastfm weeklyalbumchart [<nick>] => show <nick>'s weekly album chart")
125 when :weeklyartistchart
126 _("lastfm weeklyartistchart [<nick>] => show <nick>'s weekly artist chart")
127 when :weeklytrackchart
128 _("lastfm weeklyartistchart [<nick>] => show <nick>'s weekly track chart")
130 _("last.fm plugin - topics: events, artist, album, track, now, set, who, compare, shouts, friends, neighbors, (loved|recent)tracks, top(albums|tracks|artists), weekly(album|artist|track)chart")
134 # TODO allow searching by country etc.
136 # Options: name, limit
137 def search_venue_by(options)
139 params[:venue] = CGI.escape(options[:name])
140 options.delete(:name)
141 params.merge!(options)
143 uri = "#{APIURL}method=venue.search&"
144 uri << params.to_a.map {|e| e.join("=")}.join("&")
146 xml = @bot.httputil.get_response(uri)
147 doc = Document.new xml.body
150 doc.root.elements.each("results/venuematches/venue") do |v|
151 venue = LastFmVenue.new
152 venue.id = v.elements["id"].text.to_i
153 venue.url = v.elements["url"].text
154 venue.lat = v.elements["location/geo:point/geo:lat"].text.to_f
155 venue.long = v.elements["location/geo:point/geo:long"].text.to_f
156 venue.name = v.elements["name"].text
157 venue.city = v.elements["location/city"].text
158 venue.street = v.elements["location/street"].text
159 venue.postal = v.elements["location/postalcode"].text
160 venue.country = v.elements["location/country"].text
167 def find_events(m, params)
168 num = params[:num] || @bot.config['lastfm.default_events']
169 num = num.to_i.clip(1, @bot.config['lastfm.max_events'])
171 location = params[:location]
172 artist = params[:who]
173 venue = params[:venue]
174 user = resolve_username(m, params[:user])
177 uri = "#{APIURL}method=geo.getevents&location=#{CGI.escape location.to_s}"
178 emptymsg = _("no events found in %{location}") % {:location => location.to_s}
180 venues = search_venue_by(:name => venue.to_s, :limit => 1)
182 uri = "#{APIURL}method=venue.getevents&venue=#{venue.id}"
184 uri = "#{APIURL}method=artist.getevents&artist=#{CGI.escape artist.to_s}"
185 emptymsg = _("no events found by %{artist}") % {:artist => artist.to_s}
187 uri = "#{APIURL}method=user.getevents&user=#{CGI.escape user}"
188 emptymsg = _("%{user} is not attending any events") % {:user => user}
190 xml = @bot.httputil.get_response(uri)
192 doc = Document.new xml.body
193 if xml.class == Net::HTTPInternalServerError
194 if doc.root and doc.root.attributes["status"] == "failed"
195 m.reply doc.root.elements["error"].text
197 m.reply _("could not retrieve events")
200 disp_events = Array.new
202 doc.root.elements.each("events/event"){ |e|
204 h[:title] = e.elements["title"].text
205 venue = e.elements["venue"].elements["name"].text
206 city = e.elements["venue"].elements["location"].elements["city"].text
207 country = e.elements["venue"].elements["location"].elements["country"].text
208 h[:location] = Underline + venue + Underline + " #{Bold + city + Bold}, #{country}"
209 date = e.elements["startDate"].text.split
210 h[:date] = Time.utc(date[3].to_i, date[2], date[1].to_i)
211 h[:desc] = e.elements["description"].text
212 h[:url] = e.elements["url"].text
213 h[:attendance] = e.elements["attendance"].text.to_i
215 e.elements.each("artists/artist"){ |a|
218 h[:artists] = artists
219 events << LastFmEvent.new(h)
225 events[0...num].each { |event|
226 disp_events << event.to_s
228 m.reply disp_events.join(' | '), :split_at => /\s+\|\s+/
232 def tasteometer(m, params)
233 opts = { :cache => false }
234 user1 = resolve_username(m, params[:user1])
235 user2 = resolve_username(m, params[:user2])
236 xml = @bot.httputil.get_response("#{APIURL}method=tasteometer.compare&type1=user&type2=user&value1=#{CGI.escape user1}&value2=#{CGI.escape user2}", opts)
237 doc = Document.new xml.body
239 m.reply _("last.fm parsing failed")
242 if xml.class == Net::HTTPBadRequest
243 if doc.root.elements["error"].attributes["code"] == "7" then
244 error = doc.root.elements["error"].text
245 error.match(/Invalid username: \[(.*)\]/);
248 m.reply _("%{u} doesn't exist on last.fm") % {:u => baduser}
251 m.reply _("error: %{e}") % {:e => doc.root.element["error"].text}
255 score = doc.root.elements["comparison/result/score"].text.to_f
256 artists = doc.root.get_elements("comparison/result/artists/artist").map { |e| e.elements["name"].text}
261 rating = _("Very High")
269 rating = _("Very Low")
272 common_artists = unless artists.empty?
273 _(" and music they have in common includes: %{artists}") % {
274 :artists => Utils.comma_list(artists) }
279 m.reply _("%{a}'s and %{b}'s musical compatibility rating is %{bold}%{r}%{bold}%{common}") % {
282 :r => rating.downcase,
284 :common => common_artists
288 def now_playing(m, params)
289 opts = { :cache => false }
290 user = resolve_username(m, params[:who])
291 xml = @bot.httputil.get_response("#{APIURL}method=user.getrecenttracks&user=#{CGI.escape user}", opts)
292 doc = Document.new xml.body
294 m.reply _("last.fm parsing failed")
297 if xml.class == Net::HTTPBadRequest
298 if doc.root.elements["error"].text == "Invalid user name supplied" then
299 m.reply _("%{user} doesn't exist on last.fm, perhaps they need to: lastfm user <username>") % {
304 m.reply _("error: %{e}") % {:e => doc.root.element["error"].text}
308 now = artist = track = albumtxt = date = nil
309 unless doc.root.elements[1].has_elements?
310 m.reply _("%{u} hasn't played anything recently") % {:u => user}
313 first = doc.root.elements[1].elements[1]
314 now = first.attributes["nowplaying"]
315 artist = first.elements["artist"].text
316 track = first.elements["name"].text
317 albumtxt = first.elements["album"].text
319 year = get_album(artist, albumtxt)[2]
321 _(" [%{albumtext}, %{year}]") % { :albumtext => albumtxt, :year => year }
323 _(" [%{albumtext}]") % { :albumtext => albumtxt }
329 date = XPath.first(first, "//date")
331 time = date.attributes["uts"]
332 past = Time.at(time.to_i)
335 verb = _("is listening to")
336 if @registry.has_key? "#{m.sourcenick}_verb_present"
337 verb = @registry["#{m.sourcenick}_verb_present"]
339 reply = _("%{u} %{v} \"%{t}\" by %{a}%{b}") % {:u => user, :v => verb, :t => track, :a => artist, :b => album}
341 verb = _("listened to")
342 if @registry.has_key? "#{m.sourcenick}_verb_past"
343 verb = @registry["#{m.sourcenick}_verb_past"]
345 ago = Utils.timeago(past)
346 reply = _("%{u} %{v} \"%{t}\" by %{a}%{b} %{p}") % {:u => user, :v => verb, :t => track, :a => artist, :b => album, :p => ago}
349 reply << _("; see %{uri} for more") % { :uri => "http://www.last.fm/user/#{CGI.escape user}"}
353 def find_artist(m, params)
354 info_xml = @bot.httputil.get("#{APIURL}method=artist.getinfo&artist=#{CGI.escape params[:artist].to_s}")
356 m.reply _("I had problems getting info for %{a}") % {:a => params[:artist]}
359 info_doc = Document.new info_xml
361 m.reply _("last.fm parsing failed")
364 tags_xml = @bot.httputil.get("#{APIURL}method=artist.gettoptags&artist=#{CGI.escape params[:artist].to_s}")
365 tags_doc = Document.new tags_xml
367 first = info_doc.root.elements["artist"]
368 artist = first.elements["name"].text
369 url = first.elements["url"].text
371 %w(playcount listeners).each do |e|
372 t = first.elements["stats/#{e}"].text
373 stats[e.to_sym] = t.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")
375 summary = first.elements["bio"].elements["summary"].text
376 similar = first.get_elements("similar/artist").map { |a|
377 _("%{b}%{a}%{b}") % { :a => a.elements["name"].text, :b => Bold } }
378 tags = tags_doc.root.get_elements("toptags/tag")[0..4].map { |t|
379 _("%{u}%{t}%{u}") % { :t => t.elements["name"].text, :u => Underline } }
380 reply = _("%{b}%{a}%{b} <%{u}> has been played %{b}%{c}%{b} times and is being listened to by %{b}%{l}%{b} people") % {
381 :b => Bold, :a => artist, :u => url, :c => stats[:playcount], :l => stats[:listeners] }
382 reply << _(". Tagged as: %{t}") % {
383 :t => tags.join(", "), :b => Bold } unless tags.empty?
384 reply << _(". Similar artists: %{s}") % {
385 :s => similar.join(", "), :b => Bold } unless similar.empty?
387 m.reply summary.ircify_html
390 def find_track(m, params)
391 track = params[:track].to_s
392 xml = @bot.httputil.get("#{APIURL}method=track.search&track=#{CGI.escape track}")
394 m.reply _("I had problems getting info for %{a}") % {:a => track}
398 doc = Document.new xml
400 m.reply _("last.fm parsing failed")
404 results = doc.root.elements["results/opensearch:totalResults"].text.to_i rescue 0
408 doc.root.each_element("results/trackmatches/track") do |track|
409 hits << _("%{bold}%{t}%{bold} by %{bold}%{a}%{bold} (%{n} listeners)") % {
410 :t => track.elements["name"].text,
411 :a => track.elements["artist"].text,
412 :n => track.elements["listeners"].text,
416 m.reply hits.join(' -- '), :split_at => ' -- '
419 m.reply _("last.fm parsing failed")
422 m.reply _("track %{a} not found") % {:a => track}
426 def find_venue(m, params)
427 venue = params[:venue].to_s
428 venues = search_venue_by(:name => venue, :limit => 1)
432 m.reply "sorry, can't find such venue"
436 reply = _("%{b}%{name}%{b}, %{street}, %{u}%{city}%{u}, %{country}, see %{url} for more info") % {
437 :u => Underline, :b => Bold, :name => venue.name, :city => venue.city, :street => venue.street,
438 :country => venue.country, :url => venue.url
441 if venue.street && venue.city
442 maps_uri = "http://maps.google.com/maps?q=#{venue.street},+#{venue.city}"
443 maps_uri << ",+#{venue.postal}" if venue.postal
444 elsif venue.lat && venue.long
445 maps_uri = "http://maps.google.com/maps?q=#{venue.lat},+#{venue.long}"
451 maps_uri << "+(#{venue.name.gsub(" ", "%A0")})"
455 maps_uri = ShortURL.shorten(CGI.escape(maps_uri))
456 rescue LoadError => e
460 reply << _(" and %{maps} for maps") % { :maps => maps_uri, :b => Bold }
464 def get_album(artist, album)
465 xml = @bot.httputil.get("#{APIURL}method=album.getinfo&artist=#{CGI.escape artist}&album=#{CGI.escape album}")
467 return [_("I had problems getting album info")]
469 doc = Document.new xml
471 return [_("last.fm parsing failed")]
473 album = date = playcount = artist = date = year = nil
474 first = doc.root.elements["album"]
475 artist = first.elements["artist"].text
476 playcount = first.elements["playcount"].text
477 album = first.elements["name"].text
478 date = first.elements["releasedate"].text
479 unless date.strip.length < 2
480 year = date.strip.split[2].chop
482 result = [artist, album, year, playcount]
486 def find_album(m, params)
487 album = get_album(params[:artist].to_s, params[:album].to_s)
489 m.reply _("I couldn't locate: \"%{a}\" by %{r}") % {:a => params[:album], :r => params[:artist]}
492 year = "(#{album[2]}) " unless album[2] == nil
493 m.reply _("the album \"%{a}\" by %{r} %{y}has been played %{c} times") % {:a => album[1], :r => album[0], :y => year, :c => album[3]}
496 def set_user(m, params)
497 user = params[:who].to_s
499 @registry[ nick ] = user
500 m.reply _("okay, I'll remember that %{n} is %{u} on last.fm") % {:n => nick, :u => user}
503 def set_verb(m, params)
504 past = params[:past].to_s
505 present = params[:present].to_s
506 key = "#{m.sourcenick}_verb_"
507 @registry[ "#{key}past" ] = past
508 @registry[ "#{key}present" ] = present
509 m.reply _("okay, I'll remember that %{n} prefers \"%{r}\" and \"%{p}\"") % {:n => m.sourcenick, :p => past, :r => present}
512 def get_user(m, params)
515 nick = params[:who].to_s
519 if @registry.has_key? nick
520 user = @registry[ nick ]
521 m.reply _("%{nick} is %{user} on last.fm") % {
526 m.reply _("sorry, I don't know who %{n} is on last.fm, perhaps they need to: lastfm set user <username>") % {:n => nick}
530 def lastfm(m, params)
531 action = case params[:action]
532 when "neighbors" then "neighbours"
533 when "recentracks", "recent" then "recenttracks"
534 when "loved" then "lovedtracks"
535 when /^weekly(track|album|artist)s$/
538 find_events(m, params)
545 num = params[:num] || @bot.config['lastfm.default_shouts']
546 num = num.to_i.clip(1, @bot.config['lastfm.max_shouts'])
548 num = params[:num] || @bot.config['lastfm.default_user_data']
549 num = num.to_i.clip(1, @bot.config['lastfm.max_user_data'])
552 user = resolve_username(m, params[:user])
553 uri = "#{APIURL}method=user.get#{action}&user=#{CGI.escape user}"
555 if period = params[:period]
556 period_uri = (period.last == "year" ? "12month" : period.first + "month")
557 uri << "&period=#{period_uri}"
561 res = @bot.httputil.get_response(uri)
562 raise _("no response body") unless res.body
563 rescue Exception => e
564 m.reply _("I had problems accessing last.fm: %{e}") % {:e => e.message}
567 doc = Document.new(res.body)
569 m.reply _("last.fm parsing failed")
574 when Net::HTTPBadRequest
575 if doc.root and doc.root.attributes["status"] == "failed"
576 m.reply "error: " << doc.root.elements["error"].text.downcase
581 seemore = _("; see %{uri} for more")
584 friends = doc.root.get_elements("friends/user").map do |u|
585 u.elements["name"].text
589 reply = _("%{user} has no friends :(")
590 elsif friends.length <= num
591 reply = _("%{user} has %{total} friends: %{friends}")
593 reply = _("%{user} has %{total} friends, including %{friends}%{seemore}")
597 :total => friends.size,
598 :friends => Utils.comma_list(friends.shuffle[0, num]),
599 :uri => "http://www.last.fm/user/#{CGI.escape user}/friends",
603 loved = doc.root.get_elements("lovedtracks/track").map do |track|
604 [track.elements["artist/name"].text, track.elements["name"].text].join(" - ")
606 loved_prep = loved.shuffle[0, num].to_enum(:each_with_index).collect { |e,i| (i % 2).zero? ? Underline+e+Underline : e }
609 reply = _("%{user} has not loved any tracks")
610 elsif loved.length <= num
611 reply = _("%{user} has loved %{total} tracks: %{tracks}")
613 reply = _("%{user} has loved %{total} tracks, including %{tracks}%{seemore}")
617 :total => loved.size,
618 :tracks => Utils.comma_list(loved_prep),
619 :uri => "http://www.last.fm/user/#{CGI.escape user}/library/loved",
623 nbrs = doc.root.get_elements("neighbours/user").map do |u|
624 u.elements["name"].text
628 reply = _("no one seems to share %{user}'s musical taste")
629 elsif nbrs.length <= num
630 reply = _("%{user}'s musical neighbours are %{nbrs}")
632 reply = _("%{user}'s musical neighbours include %{nbrs}%{seemore}")
636 :nbrs => Utils.comma_list(nbrs.shuffle[0, num]),
637 :uri => "http://www.last.fm/user/#{CGI.escape user}/neighbours",
641 tracks = doc.root.get_elements("recenttracks/track").map do |track|
642 [track.elements["artist"].text, track.elements["name"].text].join(" - ")
646 tracks.each do |track|
647 if t = counts.assoc(track)
648 counts[counts.rindex(t)] = [track, t[-1] += 1]
654 tracks_prep = counts[0, num].to_enum(:each_with_index).map do |e,i|
655 str = (i % 2).zero? ? Underline+e[0]+Underline : e[0]
656 str << " (%{i} times%{m})" % {
658 :m => counts.size == 1 ? _(" or more") : nil
664 m.reply _("%{user} hasn't played anything recently") % { :user => user }
666 m.reply _("%{user} has recently played %{tracks}") %
667 { :user => user, :tracks => Utils.comma_list(tracks_prep) }
670 shouts = doc.root.get_elements("shouts/shout")
672 m.reply _("there are no shouts for %{user}") % { :user => user }
674 shouts[0, num].each do |shout|
675 m.reply _("<%{author}> %{body}") % {
676 :body => shout.elements["body"].text,
677 :author => shout.elements["author"].text,
681 when :toptracks, :topalbums, :topartists, :weeklytrackchart, :weeklyalbumchart, :weeklyartistchart
682 type = action.to_s.scan(/track|album|artist/).to_s
683 items = doc.root.get_elements("#{action}/#{type}").map do |item|
685 when :weeklytrackchart, :weeklyalbumchart
686 format = "%{artist} - %{title} (%{bold}%{plays}%{bold})"
687 artist = item.elements["artist"].text
688 when :weeklyartistchart, :topartists
689 format = "%{artist} (%{bold}%{plays}%{bold})"
690 artist = item.elements["name"].text
691 when :toptracks, :topalbums
692 format = "%{artist} - %{title} (%{bold}%{plays}%{bold})"
693 artist = item.elements["artist/name"].text
698 :title => item.elements["name"].text,
699 :plays => item.elements["playcount"].text,
704 m.reply _("%{user} hasn't played anything in this period of time") % { :user => user }
706 m.reply items[0, num].join(", ")
711 def resolve_username(m, name)
712 name = m.sourcenick if name.nil?
713 @registry[name] or name
717 plugin = LastFmPlugin.new
718 plugin.map 'lastfm [:num] event[s] in *location', :action => :find_events, :requirements => { :num => /\d+/ }, :thread => true
719 plugin.map 'lastfm [:num] event[s] by *who', :action => :find_events, :requirements => { :num => /\d+/ }, :thread => true
720 plugin.map 'lastfm [:num] event[s] at *venue', :action => :find_events, :requirements => { :num => /\d+/ }, :thread => true
721 plugin.map 'lastfm [:num] event[s] [for] *who', :action => :find_events, :requirements => { :num => /\d+/ }, :thread => true
722 plugin.map 'lastfm artist *artist', :action => :find_artist, :thread => true
723 plugin.map 'lastfm album *album [by *artist]', :action => :find_album
724 plugin.map 'lastfm track *track', :action => :find_track, :thread => true
725 plugin.map 'lastfm venue *venue', :action => :find_venue, :thread => true
726 plugin.map 'lastfm set user[name] :who', :action => :set_user, :thread => true
727 plugin.map 'lastfm set verb *present, *past', :action => :set_verb, :thread => true
728 plugin.map 'lastfm who [:who]', :action => :get_user, :thread => true
729 plugin.map 'lastfm compare to :user2', :action => :tasteometer, :thread => true
730 plugin.map 'lastfm compare [:user1] [to] :user2', :action => :tasteometer, :thread => true
731 plugin.map "lastfm [user] [:num] :action [:user]", :thread => true,
733 :action => /^(?:events|shouts|friends|neighbou?rs|loved(?:tracks)?|recent(?:t?racks)?|top(?:album|artist|track)s?|weekly(?:albums?|artists?|tracks?)(?:chart)?)$/,
736 plugin.map 'lastfm [user] [:num] :action [:user] over [*period]', :thread => true,
738 :action => /^(?:top(?:album|artist|track)s?)$/,
739 :period => /^(?:(?:3|6|12) months)|(?:a\s|1\s)?year$/,
742 plugin.map 'lastfm [now] [:who]', :action => :now_playing, :thread => true
743 plugin.map 'np [:who]', :action => :now_playing, :thread => true