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'
22 attr_reader :attendance, :date
27 @location = hash[:location]
28 @description = hash[:description]
29 @attendance = hash[:attendance]
31 @artists = hash[:artists]
33 if @artists.length > 10 #more than 10 artists and it floods
34 diff = @artists.length - 10
35 @artist_string = Bold + @artists[0..10].join(', ') + Bold
36 @artist_string << _(" and %{n} more...") % {:n => diff}
38 @artist_string = Bold + @artists.join(', ') + Bold
43 unless @attendance.zero?
44 return "%s %s @ %s (%s attending) %s" % [@date.strftime("%a, %b %d"), @artist_string, @location, @attendance, @url]
46 return "%s %s @ %s %s" % [@date.strftime("%a, %b %d"), @artist_string, @location, @url]
48 alias :to_s :compact_display
52 define_structure :LastFmVenue, :id, :city, :street, :postal, :country, :name, :url, :lat, :long
53 class ::Struct::LastFmVenue
57 str << " (" << [self.city, self.country].compact.join(", ") << ")"
63 class LastFmPlugin < Plugin
65 Config.register Config::IntegerValue.new('lastfm.max_events',
66 :default => 25, :validate => Proc.new{|v| v > 1},
67 :desc => "Maximum number of events to display.")
68 Config.register Config::IntegerValue.new('lastfm.default_events',
69 :default => 3, :validate => Proc.new{|v| v > 1},
70 :desc => "Default number of events to display.")
71 Config.register Config::IntegerValue.new('lastfm.max_shouts',
72 :default => 5, :validate => Proc.new{|v| v > 1},
73 :desc => "Maximum number of user shouts to display.")
74 Config.register Config::IntegerValue.new('lastfm.default_shouts',
75 :default => 3, :validate => Proc.new{|v| v > 1},
76 :desc => "Default number of user shouts to display.")
77 Config.register Config::IntegerValue.new('lastfm.max_user_data',
78 :default => 25, :validate => Proc.new{|v| v > 1},
79 :desc => "Maximum number of user data entries (except events and shouts) to display.")
80 Config.register Config::IntegerValue.new('lastfm.default_user_data',
81 :default => 10, :validate => Proc.new{|v| v > 1},
82 :desc => "Default number of user data entries (except events and shouts) to display.")
84 APIKEY = "b25b959554ed76058ac220b7b2e0a026"
85 APIURL = "http://ws.audioscrobbler.com/2.0/?api_key=#{APIKEY}&"
99 def help(plugin, topic="")
100 period = _(", where <period> can be one of: 3|6|12 months, a year")
101 case (topic.intern rescue nil)
103 _("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>. lastfm [<num>] events at <venue> => show information on events at specific <venue>. The number of events <num> that can be displayed is optional, defaults to %{d} and cannot be higher than %{m}. Append 'sort by <what> [in <order> order]' to sort events. Events can be sorted by attendance or date (default) in ascending or descending order.") % {:d => @bot.config['lastfm.default_events'], :m => @bot.config['lastfm.max_events']}
105 _("lastfm artist <name> => show information on artist <name> from last.fm")
107 _("lastfm album <name> => show information on album <name> from last.fm [not implemented yet]")
109 _("lastfm track <name> => search tracks matching <name> on last.fm")
111 _("lastfm now [<nick>] => show the now playing track from last.fm. np [<nick>] does the same.")
113 _("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\".")
115 _("lastfm who [<nick>] => show who <nick> is on last.fm. if <nick> is empty, show who you are on lastfm.")
117 _("lastfm compare [<nick1>] <nick2> => show musical taste compatibility between nick1 (or user if omitted) and nick2")
119 _("lastfm shouts [<nick>] => show shouts to <nick>")
121 _("lastfm friends [<nick>] => show <nick>'s friends")
122 when :neighbors, :neighbours
123 _("lastfm neighbors [<nick>] => show people who share similar musical taste as <nick>")
125 _("lastfm loved[tracks] [<nick>] => show tracks that <nick> has loved")
126 when :recenttracks, :recentracks
127 _("lastfm recent[tracks] [<nick>] => show tracks that <nick> has recently played")
129 _("lastfm topalbums [<nick>] [over <period>] => show <nick>'s top albums%{p}") % { :p => period }
131 _("lastfm topartists [<nick>] [over <period>] => show <nick>'s top artists%{p}") % { :p => period }
133 _("lastfm toptracks [<nick>] [over <period>] => show <nick>'s top tracks%{p}") % { :p => period }
134 when :weeklyalbumchart
135 _("lastfm weeklyalbumchart [<nick>] => show <nick>'s weekly album chart")
136 when :weeklyartistchart
137 _("lastfm weeklyartistchart [<nick>] => show <nick>'s weekly artist chart")
138 when :weeklytrackchart
139 _("lastfm weeklyartistchart [<nick>] => show <nick>'s weekly track chart")
141 _("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")
145 # TODO allow searching by country etc.
147 # Options: name, limit
148 def search_venue_by(options)
150 params[:venue] = CGI.escape(options[:name])
151 options.delete(:name)
152 params.merge!(options)
154 uri = "#{APIURL}method=venue.search&"
155 uri << params.to_a.map {|e| e.join("=")}.join("&")
157 xml = @bot.httputil.get_response(uri)
158 doc = Document.new xml.body
161 doc.root.elements.each("results/venuematches/venue") do |v|
162 venue = LastFmVenue.new
163 venue.id = v.elements["id"].text.to_i
164 venue.url = v.elements["url"].text
165 venue.lat = v.elements["location/geo:point/geo:lat"].text.to_f
166 venue.long = v.elements["location/geo:point/geo:long"].text.to_f
167 venue.name = v.elements["name"].text
168 venue.city = v.elements["location/city"].text
169 venue.street = v.elements["location/street"].text
170 venue.postal = v.elements["location/postalcode"].text
171 venue.country = v.elements["location/country"].text
178 def find_events(m, params)
179 num = params[:num] || @bot.config['lastfm.default_events']
180 num = num.to_i.clip(1, @bot.config['lastfm.max_events'])
182 sort_by = params[:sort_by] || :date
183 sort_order = params[:sort_order]
184 sort_order = sort_order.to_sym unless sort_order.nil?
186 location = params[:location]
187 artist = params[:who]
188 venue = params[:venue]
189 user = resolve_username(m, params[:user])
192 uri = "#{APIURL}method=geo.getevents&location=#{CGI.escape location.to_s}"
193 emptymsg = _("no events found in %{location}") % {:location => location.to_s}
196 venues = search_venue_by(:name => venue.to_s, :limit => 1)
197 rescue Exception => e
199 m.reply _("an error occurred looking for venue %{venue}: %{e}") % {
200 :venue => venue.to_s,
206 m.reply _("no venue found matching %{venue}") % {:venue => venue.to_s}
210 uri = "#{APIURL}method=venue.getevents&venue=#{venue.id}"
211 emptymsg = _("no events found at %{venue}") % {:venue => venue.to_s}
213 uri = "#{APIURL}method=artist.getevents&artist=#{CGI.escape artist.to_s}"
214 emptymsg = _("no events found by %{artist}") % {:artist => artist.to_s}
216 uri = "#{APIURL}method=user.getevents&user=#{CGI.escape user}"
217 emptymsg = _("%{user} is not attending any events") % {:user => user}
219 xml = @bot.httputil.get_response(uri)
221 doc = Document.new xml.body
222 if xml.class == Net::HTTPInternalServerError
223 if doc.root and doc.root.attributes["status"] == "failed"
224 m.reply doc.root.elements["error"].text
226 m.reply _("could not retrieve events")
229 disp_events = Array.new
231 doc.root.elements.each("events/event"){ |e|
233 h[:title] = e.elements["title"].text
234 venue = e.elements["venue"].elements["name"].text
235 city = e.elements["venue"].elements["location"].elements["city"].text
236 country = e.elements["venue"].elements["location"].elements["country"].text
237 h[:location] = Underline + venue + Underline + " #{Bold + city + Bold}, #{country}"
238 date = e.elements["startDate"].text.split
239 h[:date] = Time.utc(date[3].to_i, date[2], date[1].to_i)
240 h[:desc] = e.elements["description"].text
241 h[:url] = e.elements["url"].text
242 h[:attendance] = e.elements["attendance"].text.to_i
244 e.elements.each("artists/artist"){ |a|
247 h[:artists] = artists
248 events << LastFmEvent.new(h)
255 # sort order when sorted by date is ascending by default
256 # and descending when sorted by attendance
259 events = events.sort_by { |e| e.attendance }.reverse
260 events.reverse! if [:ascending, :asc].include? sort_order
262 events = events.sort_by { |e| e.date }
263 events.reverse! if [:descending, :desc].include? sort_order
266 events[0...num].each { |event|
267 disp_events << event.to_s
269 m.reply disp_events.join(' | '), :split_at => /\s+\|\s+/
273 def tasteometer(m, params)
274 opts = { :cache => false }
275 user1 = resolve_username(m, params[:user1])
276 user2 = resolve_username(m, params[:user2])
277 xml = @bot.httputil.get_response("#{APIURL}method=tasteometer.compare&type1=user&type2=user&value1=#{CGI.escape user1}&value2=#{CGI.escape user2}", opts)
278 doc = Document.new xml.body
280 m.reply _("last.fm parsing failed")
283 if xml.class == Net::HTTPBadRequest
284 if doc.root.elements["error"].attributes["code"] == "7" then
285 error = doc.root.elements["error"].text
286 error.match(/Invalid username: \[(.*)\]/);
289 m.reply _("%{u} doesn't exist on last.fm") % {:u => baduser}
292 m.reply _("error: %{e}") % {:e => doc.root.element["error"].text}
296 score = doc.root.elements["comparison/result/score"].text.to_f
297 artists = doc.root.get_elements("comparison/result/artists/artist").map { |e| e.elements["name"].text}
302 rating = _("Very High")
310 rating = _("Very Low")
313 common_artists = unless artists.empty?
314 _(" and music they have in common includes: %{artists}") % {
315 :artists => Utils.comma_list(artists) }
320 m.reply _("%{a}'s and %{b}'s musical compatibility rating is %{bold}%{r}%{bold}%{common}") % {
323 :r => rating.downcase,
325 :common => common_artists
329 def now_playing(m, params)
330 opts = { :cache => false }
331 user = resolve_username(m, params[:who])
332 xml = @bot.httputil.get_response("#{APIURL}method=user.getrecenttracks&user=#{CGI.escape user}", opts)
333 doc = Document.new xml.body
335 m.reply _("last.fm parsing failed")
338 if xml.class == Net::HTTPBadRequest
339 if doc.root.elements["error"].attributes["code"] == "6" then
340 m.reply _("%{user} doesn't exist on last.fm, perhaps they need to: %{prefix}lastfm set user <username>") % {
342 :prefix => @bot.config['core.address_prefix'].first
346 m.reply _("error: %{e}") % {:e => doc.root.element["error"].text}
350 now = artist = track = albumtxt = date = nil
351 unless doc.root.elements[1].has_elements?
352 m.reply _("%{u} hasn't played anything recently") % {:u => user}
355 first = doc.root.elements[1].elements[1]
356 now = first.attributes["nowplaying"]
357 artist = first.elements["artist"].text
358 track = first.elements["name"].text
359 albumtxt = first.elements["album"].text
361 year = get_album(artist, albumtxt)[2]
363 _(" [%{albumtext}, %{year}]") % { :albumtext => albumtxt, :year => year }
365 _(" [%{albumtext}]") % { :albumtext => albumtxt }
371 date = XPath.first(first, "//date")
373 time = date.attributes["uts"]
374 past = Time.at(time.to_i)
377 verb = _("is listening to")
378 if @registry.has_key? "#{m.sourcenick}_verb_present"
379 verb = @registry["#{m.sourcenick}_verb_present"]
381 reply = _("%{u} %{v} \"%{t}\" by %{bold}%{a}%{bold}%{b}") % {:u => user, :v => verb, :t => track, :a => artist, :b => album, :bold => Bold}
383 verb = _("listened to")
384 if @registry.has_key? "#{m.sourcenick}_verb_past"
385 verb = @registry["#{m.sourcenick}_verb_past"]
387 ago = Utils.timeago(past)
388 reply = _("%{u} %{v} \"%{t}\" by %{bold}%{a}%{bold}%{b} %{p};") % {:u => user, :v => verb, :t => track, :a => artist, :b => album, :p => ago, :bold => Bold}
391 if @bot.plugins['spotify'] && Object.const_defined?('Spotify')
392 if track = Spotify.search(:track, "#{artist} #{track}")
393 reply << _(" [%{u}%{url}%{u}]") % {:u => Underline, :url => track.url}
397 reply << _(" -- see %{uri} for more") % { :uri => "http://www.last.fm/user/#{CGI.escape user}"}
401 def find_artist(m, params)
402 info_xml = @bot.httputil.get("#{APIURL}method=artist.getinfo&artist=#{CGI.escape params[:artist].to_s}")
404 m.reply _("I had problems getting info for %{a}") % {:a => params[:artist]}
407 info_doc = Document.new info_xml
409 m.reply _("last.fm parsing failed")
412 tags_xml = @bot.httputil.get("#{APIURL}method=artist.gettoptags&artist=#{CGI.escape params[:artist].to_s}")
413 tags_doc = Document.new tags_xml
415 first = info_doc.root.elements["artist"]
416 artist = first.elements["name"].text
417 url = first.elements["url"].text
419 %w(playcount listeners).each do |e|
420 t = first.elements["stats/#{e}"].text
421 stats[e.to_sym] = t.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")
423 summary = first.elements["bio"].elements["summary"].text
424 similar = first.get_elements("similar/artist").map { |a|
425 _("%{b}%{a}%{b}") % { :a => a.elements["name"].text, :b => Bold } }
426 tags = tags_doc.root.get_elements("toptags/tag")[0..4].map { |t|
427 _("%{u}%{t}%{u}") % { :t => t.elements["name"].text, :u => Underline } }
428 reply = _("%{b}%{a}%{b} <%{u}> has been played %{b}%{c}%{b} times and is being listened to by %{b}%{l}%{b} people") % {
429 :b => Bold, :a => artist, :u => url, :c => stats[:playcount], :l => stats[:listeners] }
430 reply << _(". Tagged as: %{t}") % {
431 :t => tags.join(", "), :b => Bold } unless tags.empty?
432 reply << _(". Similar artists: %{s}") % {
433 :s => similar.join(", "), :b => Bold } unless similar.empty?
435 m.reply summary.ircify_html
438 def find_track(m, params)
439 track = params[:track].to_s
440 xml = @bot.httputil.get("#{APIURL}method=track.search&track=#{CGI.escape track}")
442 m.reply _("I had problems getting info for %{a}") % {:a => track}
446 doc = Document.new xml
448 m.reply _("last.fm parsing failed")
452 results = doc.root.elements["results/opensearch:totalResults"].text.to_i rescue 0
456 doc.root.each_element("results/trackmatches/track") do |track|
457 hits << _("%{bold}%{t}%{bold} by %{bold}%{a}%{bold} (%{n} listeners)") % {
458 :t => track.elements["name"].text,
459 :a => track.elements["artist"].text,
460 :n => track.elements["listeners"].text,
464 m.reply hits.join(' -- '), :split_at => ' -- '
467 m.reply _("last.fm parsing failed")
470 m.reply _("track %{a} not found") % {:a => track}
474 def find_venue(m, params)
475 venue = params[:venue].to_s
476 venues = search_venue_by(:name => venue, :limit => 1)
480 m.reply "sorry, can't find such venue"
484 reply = _("%{b}%{name}%{b}, %{street}, %{u}%{city}%{u}, %{country}, see %{url} for more info") % {
485 :u => Underline, :b => Bold, :name => venue.name, :city => venue.city, :street => venue.street,
486 :country => venue.country, :url => venue.url
489 if venue.street && venue.city
490 maps_uri = "http://maps.google.com/maps?q=#{venue.street},+#{venue.city}"
491 maps_uri << ",+#{venue.postal}" if venue.postal
492 elsif venue.lat && venue.long
493 maps_uri = "http://maps.google.com/maps?q=#{venue.lat},+#{venue.long}"
499 maps_uri << "+(#{venue.name.gsub(" ", "%A0")})"
503 maps_uri = ShortURL.shorten(CGI.escape(maps_uri))
504 rescue LoadError => e
508 reply << _(" and %{maps} for maps") % { :maps => maps_uri, :b => Bold }
512 def get_album(artist, album)
513 xml = @bot.httputil.get("#{APIURL}method=album.getinfo&artist=#{CGI.escape artist}&album=#{CGI.escape album}")
515 return [_("I had problems getting album info")]
517 doc = Document.new xml
519 return [_("last.fm parsing failed")]
521 album = date = playcount = artist = date = year = nil
522 first = doc.root.elements["album"]
523 artist = first.elements["artist"].text
524 playcount = first.elements["playcount"].text
525 album = first.elements["name"].text
526 date = first.elements["releasedate"].text
527 unless date.strip.length < 2
528 year = date.strip.split[2].chop
530 result = [artist, album, year, playcount]
534 def find_album(m, params)
535 album = get_album(params[:artist].to_s, params[:album].to_s)
537 m.reply _("I couldn't locate: \"%{a}\" by %{r}") % {:a => params[:album], :r => params[:artist]}
540 year = "(#{album[2]}) " unless album[2] == nil
541 m.reply _("the album \"%{a}\" by %{r} %{y}has been played %{c} times") % {:a => album[1], :r => album[0], :y => year, :c => album[3]}
544 def set_user(m, params)
545 user = params[:who].to_s
547 @registry[ nick ] = user
548 m.reply _("okay, I'll remember that %{n} is %{u} on last.fm") % {:n => nick, :u => user}
551 def set_verb(m, params)
552 past = params[:past].to_s
553 present = params[:present].to_s
554 key = "#{m.sourcenick}_verb_"
555 @registry[ "#{key}past" ] = past
556 @registry[ "#{key}present" ] = present
557 m.reply _("okay, I'll remember that %{n} prefers \"%{r}\" and \"%{p}\"") % {:n => m.sourcenick, :p => past, :r => present}
560 def get_user(m, params)
563 nick = params[:who].to_s
567 if @registry.has_key? nick
568 user = @registry[ nick ]
569 m.reply _("%{nick} is %{user} on last.fm") % {
574 m.reply _("sorry, I don't know who %{n} is on last.fm, perhaps they need to: lastfm set user <username>") % {:n => nick}
578 def lastfm(m, params)
579 action = case params[:action]
580 when "neighbors" then "neighbours"
581 when "recentracks", "recent" then "recenttracks"
582 when "loved" then "lovedtracks"
583 when /^weekly(track|album|artist)s$/
586 find_events(m, params)
593 num = params[:num] || @bot.config['lastfm.default_shouts']
594 num = num.to_i.clip(1, @bot.config['lastfm.max_shouts'])
596 num = params[:num] || @bot.config['lastfm.default_user_data']
597 num = num.to_i.clip(1, @bot.config['lastfm.max_user_data'])
600 user = resolve_username(m, params[:user])
601 uri = "#{APIURL}method=user.get#{action}&user=#{CGI.escape user}"
603 if period = params[:period]
604 period_uri = (period.last == "year" ? "12month" : period.first + "month")
605 uri << "&period=#{period_uri}"
609 res = @bot.httputil.get_response(uri)
610 raise _("no response body") unless res.body
611 rescue Exception => e
612 m.reply _("I had problems accessing last.fm: %{e}") % {:e => e.message}
615 doc = Document.new(res.body)
617 m.reply _("last.fm parsing failed")
622 when Net::HTTPBadRequest
623 if doc.root and doc.root.attributes["status"] == "failed"
624 m.reply "error: " << doc.root.elements["error"].text.downcase
629 seemore = _("; see %{uri} for more")
632 friends = doc.root.get_elements("friends/user").map do |u|
633 u.elements["name"].text
637 reply = _("%{user} has no friends :(")
638 elsif friends.length <= num
639 reply = _("%{user} has %{total} friends: %{friends}")
641 reply = _("%{user} has %{total} friends, including %{friends}%{seemore}")
645 :total => friends.size,
646 :friends => Utils.comma_list(friends.shuffle[0, num]),
647 :seemore => seemore % { :uri => "http://www.last.fm/user/#{CGI.escape user}/friends" }
650 loved = doc.root.get_elements("lovedtracks/track").map do |track|
651 [track.elements["artist/name"].text, track.elements["name"].text].join(" - ")
653 loved_prep = loved.shuffle[0, num].to_enum(:each_with_index).collect { |e,i| (i % 2).zero? ? Underline+e+Underline : e }
656 reply = _("%{user} has not loved any tracks")
657 elsif loved.length <= num
658 reply = _("%{user} has loved %{total} tracks: %{tracks}")
660 reply = _("%{user} has loved %{total} tracks, including %{tracks}%{seemore}")
665 :total => loved.size,
666 :tracks => Utils.comma_list(loved_prep),
667 :seemore => seemore % { :uri => "http://www.last.fm/user/#{CGI.escape user}/library/loved" }
670 nbrs = doc.root.get_elements("neighbours/user").map do |u|
671 u.elements["name"].text
675 reply = _("no one seems to share %{user}'s musical taste")
676 elsif nbrs.length <= num
677 reply = _("%{user}'s musical neighbours are %{nbrs}")
679 reply = _("%{user}'s musical neighbours include %{nbrs}%{seemore}")
683 :nbrs => Utils.comma_list(nbrs.shuffle[0, num]),
684 :seemore => seemore % { :uri => "http://www.last.fm/user/#{CGI.escape user}/neighbours" }
687 tracks = doc.root.get_elements("recenttracks/track").map do |track|
688 [track.elements["artist"].text, track.elements["name"].text].join(" - ")
692 tracks.each do |track|
693 if t = counts.assoc(track)
694 counts[counts.rindex(t)] = [track, t[-1] += 1]
700 tracks_prep = counts[0, num].to_enum(:each_with_index).map do |e,i|
701 str = (i % 2).zero? ? Underline+e[0]+Underline : e[0]
702 str << " (%{i} times%{m})" % {
704 :m => counts.size == 1 ? _(" or more") : nil
710 m.reply _("%{user} hasn't played anything recently") % { :user => user }
712 m.reply _("%{user} has recently played %{tracks}") %
713 { :user => user, :tracks => Utils.comma_list(tracks_prep) }
716 shouts = doc.root.get_elements("shouts/shout")
718 m.reply _("there are no shouts for %{user}") % { :user => user }
720 shouts[0, num].each do |shout|
721 m.reply _("<%{author}> %{body}") % {
722 :body => shout.elements["body"].text,
723 :author => shout.elements["author"].text,
727 when :toptracks, :topalbums, :topartists, :weeklytrackchart, :weeklyalbumchart, :weeklyartistchart
728 type = action.to_s.scan(/track|album|artist/).to_s
729 items = doc.root.get_elements("#{action}/#{type}").map do |item|
731 when :weeklytrackchart, :weeklyalbumchart
732 format = "%{artist} - %{title} (%{bold}%{plays}%{bold})"
733 artist = item.elements["artist"].text
734 when :weeklyartistchart, :topartists
735 format = "%{artist} (%{bold}%{plays}%{bold})"
736 artist = item.elements["name"].text
737 when :toptracks, :topalbums
738 format = "%{artist} - %{title} (%{bold}%{plays}%{bold})"
739 artist = item.elements["artist/name"].text
744 :title => item.elements["name"].text,
745 :plays => item.elements["playcount"].text,
750 m.reply _("%{user} hasn't played anything in this period of time") % { :user => user }
752 m.reply items[0, num].join(", ")
757 def resolve_username(m, name)
758 name = m.sourcenick if name.nil?
759 @registry[name] or name
763 event_map_options = {
764 :action => :find_events,
767 :sort_order => /(?:asc|desc)(?:ending)?/
772 plugin = LastFmPlugin.new
773 plugin.map 'lastfm [:num] event[s] in *location [sort[ed] by :sort_by] [[in] :sort_order [order]]', event_map_options.dup
774 plugin.map 'lastfm [:num] event[s] by *who [sort[ed] by :sort_by] [[in] :sort_order [order]]', event_map_options.dup
775 plugin.map 'lastfm [:num] event[s] at *venue [sort[ed] by :sort_by] [[in] :sort_order [order]]', event_map_options.dup
776 plugin.map 'lastfm [:num] event[s] [for] *who [sort[ed] by :sort_by] [[in] :sort_order [order]]', event_map_options.dup
777 plugin.map 'lastfm artist *artist', :action => :find_artist, :thread => true
778 plugin.map 'lastfm album *album [by *artist]', :action => :find_album
779 plugin.map 'lastfm track *track', :action => :find_track, :thread => true
780 plugin.map 'lastfm venue *venue', :action => :find_venue, :thread => true
781 plugin.map 'lastfm set user[name] :who', :action => :set_user, :thread => true
782 plugin.map 'lastfm set verb *present, *past', :action => :set_verb, :thread => true
783 plugin.map 'lastfm who [:who]', :action => :get_user, :thread => true
784 plugin.map 'lastfm compare to :user2', :action => :tasteometer, :thread => true
785 plugin.map 'lastfm compare [:user1] [to] :user2', :action => :tasteometer, :thread => true
786 plugin.map "lastfm [user] [:num] :action [:user]", :thread => true,
788 :action => /^(?:events|shouts|friends|neighbou?rs|loved(?:tracks)?|recent(?:t?racks)?|top(?:album|artist|track)s?|weekly(?:albums?|artists?|tracks?)(?:chart)?)$/,
791 plugin.map 'lastfm [user] [:num] :action [:user] over [*period]', :thread => true,
793 :action => /^(?:top(?:album|artist|track)s?)$/,
794 :period => /^(?:(?:3|6|12) months)|(?:a\s|1\s)?year$/,
797 plugin.map 'lastfm [now] [:who]', :action => :now_playing, :thread => true
798 plugin.map 'np [:who]', :action => :now_playing, :thread => true