/lib/DDG/Spice/Lastfm/ArtistAlbum.pm

https://github.com/pardocz/zeroclickinfo-spice · Perl · 38 lines · 30 code · 7 blank · 1 comment · 4 complexity · 88966dbfea8d17a1e140605f1470cb19 MD5 · raw file

  1. package DDG::Spice::Lastfm::ArtistAlbum;
  2. # ABSTRACT: Get the albums of a musician.
  3. use DDG::Spice;
  4. primary_example_queries "albums from Ben Folds";
  5. description "Top albums from an artist";
  6. name "LastFM Artist Album";
  7. icon_url "/i/www.last.fm.ico";
  8. source "Last.fm";
  9. code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/Lastfm/ArtistAlbum.pm";
  10. topics "entertainment", "music";
  11. category "entertainment";
  12. attribution github => ['https://github.com/jagtalon','Jag Talon'],
  13. twitter => ['http://twitter.com/juantalon','Jag Talon'];
  14. spice to => 'http://ws.audioscrobbler.com/2.0/?limit=5&format=json&method=artist.gettopalbums&artist=$1&autocorrect=1&api_key={{ENV{DDG_SPICE_LASTFM_APIKEY}}}&callback={{callback}}';
  15. my $synonyms = "albums?|records?|cds?";
  16. triggers query_lc => qr/^(?:$synonyms)\s+(?:(?:by|from|of)\s+)?([^\s]+(?:\s+[^\s]+)*)$
  17. |
  18. ^([^\s]+(?:\s+[^\s]+)*)\s+(?:$synonyms)$
  19. |
  20. ^([^\s]+(?:\s+[^\s]+)*)\s+(?:discography)$
  21. |
  22. ^(?:discography)\s+([^\s]+(?:\s+[^\s]+)*)$
  23. /x;
  24. handle matches => sub {
  25. return $1 if $1;
  26. return $2 if $2;
  27. return $3 if $3;
  28. return $4 if $4;
  29. return;
  30. };
  31. 1;