PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/DDG/Spice/Songkick/Getartistid.pm

http://github.com/duckduckgo/zeroclickinfo-spice
Perl | 36 lines | 27 code | 6 blank | 3 comment | 2 complexity | 0c16de70950289708309292c1df2190d MD5 | raw file
Possible License(s): Apache-2.0
  1. package DDG::Spice::Songkick::Getartistid;
  2. # ABSTRACT: Get similar artists for an artist
  3. use strict;
  4. use warnings;
  5. use DDG::Spice;
  6. name "Songkick Artists";
  7. description "Find similar artists.";
  8. source "Songkick";
  9. primary_example_queries "artists like Fleetwood Mac";
  10. secondary_example_queries "artists similar to Eric Clapton";
  11. category "entertainment";
  12. topics "entertainment", "everyday", "music";
  13. # FIXME Point to the duckduckgo repository on pull.
  14. code_url "https://github.com/bradcater/zeroclickinfo-spice/blob/master/lib/DDG/Spice/Songkick/Artists.pm";
  15. attribution github => ["https://github.com/bradcater", "Brad Cater"],
  16. twitter => ["https://twitter.com/bradcater", "Brad Cater"];
  17. triggers start => "artists", "bands", "musicians";
  18. spice to => 'http://api.songkick.com/api/3.0/search/artists.json?apikey={{ENV{DDG_SPICE_SONGKICK_APIKEY}}}&per_page=1&query=$1&jsoncallback={{callback}}';
  19. handle remainder => sub {
  20. # If the query isn't blank, then use it for the API query.
  21. if (length($_) > 0) {
  22. if ($_ =~ /^like (.+)$/) {
  23. return $1;
  24. } elsif ($_ =~ /^similar to (.+)$/) {
  25. return $1;
  26. }
  27. }
  28. return;
  29. };
  30. 1;