/lib/DDG/Spice/SeatGeek.pm

https://github.com/pardocz/zeroclickinfo-spice · Perl · 32 lines · 21 code · 6 blank · 5 comment · 1 complexity · e0041b59fe761e839a6a74d9c931095c MD5 · raw file

  1. package DDG::Spice::SeatGeek;
  2. # ABSTRACT: Returns upcoming concerts for a band/artist.
  3. use DDG::Spice;
  4. primary_example_queries "live show weezer", "upcoming concerts in flames";
  5. description "Upcoming concerts from SeatGeek";
  6. name "SeatGeek";
  7. code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/SeatGeek.pm";
  8. category "entertainment";
  9. topics "entertainment", "music";
  10. attribution github => ['https://github.com/MariagraziaAlastra','MariagraziaAlastra'];
  11. triggers startend => 'upcoming concert', 'upcoming concerts', 'concert', 'concerts', 'live', 'live show', 'live shows';
  12. spice to => 'http://api.seatgeek.com/2/events?performers.slug=$1';
  13. spice wrap_jsonp_callback => 1;
  14. handle remainder_lc => sub {
  15. # Removes triggers from the query
  16. $_ =~ s/^(:?(upcoming\s*)?(concerts?))|((live)\s*(:?(shows?))?)$//gi;
  17. # Removes spaces from the beginning of the query
  18. $_ =~ s/^\s+//;
  19. # Removes spaces from the end of the query
  20. $_ =~ s/\s+$//;
  21. # Replaces spaces between words with dashes, because the API requires it
  22. $_ =~ s/\s/\-/g;
  23. return $_ if $_;
  24. return;
  25. };
  26. 1;