PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://github.com/robertbrook/zeroclickinfo-spice
Perl | 35 lines | 27 code | 6 blank | 2 comment | 2 complexity | 383db0bca601166f57007f08bbb99fcd MD5 | raw file
  1. package DDG::Spice::Songkick::Getartistid;
  2. use strict;
  3. use warnings;
  4. use DDG::Spice;
  5. name "Songkick Artists";
  6. description "Find similar artists.";
  7. source "Songkick";
  8. primary_example_queries "artists like Fleetwood Mac";
  9. secondary_example_queries "artists similar to Eric Clapton";
  10. category "entertainment";
  11. topics "entertainment", "everyday", "music";
  12. # FIXME Point to the duckduckgo repository on pull.
  13. code_url "https://github.com/bradcater/zeroclickinfo-spice/blob/master/lib/DDG/Spice/Songkick/Artists.pm";
  14. attribution github => ["https://github.com/bradcater", "Brad Cater"],
  15. twitter => ["https://twitter.com/bradcater", "bradcater"];
  16. triggers start => "artists", "bands", "musicians";
  17. 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}}';
  18. handle remainder => sub {
  19. # If the query isn't blank, then use it for the API query.
  20. if (length($_) > 0) {
  21. if ($_ =~ /^like (.+)$/) {
  22. return $1;
  23. } elsif ($_ =~ /^similar to (.+)$/) {
  24. return $1;
  25. }
  26. }
  27. return;
  28. };
  29. 1;