PageRenderTime 53ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/DDG/Spice/SeatGeek/EventsByArtist.pm

http://github.com/duckduckgo/zeroclickinfo-spice
Perl | 41 lines | 27 code | 9 blank | 5 comment | 2 complexity | ed52128f8288c7d2cb44e61d7808c5dc MD5 | raw file
Possible License(s): Apache-2.0
  1. package DDG::Spice::SeatGeek::EventsByArtist;
  2. # ABSTRACT: Returns upcoming concerts for a band/artist.
  3. use strict;
  4. use DDG::Spice;
  5. use Text::Trim;
  6. triggers startend =>
  7. 'upcoming concert',
  8. 'upcoming concerts',
  9. 'concert',
  10. 'concerts',
  11. 'live',
  12. 'live show',
  13. 'live shows',
  14. 'gigs',
  15. 'tickets',
  16. 'event',
  17. 'events';
  18. spice proxy_cache_valid => "200 304 12h";
  19. spice to => 'https://api.seatgeek.com/2/events?taxonomies.name=concert&per_page=20&performers.slug=$1&callback={{callback}}';
  20. handle remainder_lc => sub {
  21. # in case we've matched for example "upcoming bjork concerts"
  22. $_ =~ s/^upcoming\s//;
  23. # If query starts with any of these assume it's one of the other queries
  24. return if ($_ =~ /^(in |at |near me|nearby)/);
  25. # Removes spaces from the beginning and end of the query
  26. $_ = trim($_);
  27. # Replaces spaces between words with dashes, because the API requires it
  28. $_ =~ s/\s/\-/g;
  29. return $_ if $_;
  30. return;
  31. };
  32. 1;