PageRenderTime 23ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/DDG/Spice/Tvmaze/Nextepisode.pm

http://github.com/duckduckgo/zeroclickinfo-spice
Perl | 33 lines | 19 code | 12 blank | 2 comment | 5 complexity | 14c33202b6bbf5dfd2d907cf7f353bee MD5 | raw file
Possible License(s): Apache-2.0
  1. package DDG::Spice::Tvmaze::Nextepisode;
  2. # ABSTRACT: Information about the next episode of TV series
  3. use strict;
  4. use DDG::Spice;
  5. # the next episode will change the moment an episode has aired, so cache it for just one hour
  6. spice is_cached => 1;
  7. spice proxy_cache_valid => "200 301 302 404 1h";
  8. triggers any => 'episode', 'airdate';
  9. triggers start => 'when does';
  10. spice to => 'http://api.tvmaze.com/singlesearch/shows?q=$1&embed=nextepisode';
  11. spice wrap_jsonp_callback => 1;
  12. handle query_lc => sub {
  13. return unless $_;
  14. return $4 if $_ =~ /(next|upcoming) (episode|airdate) (in|of|for|from)? ?(.+)/;
  15. return $2 if $_ =~ /(next|upcoming) (.+?) episode/;
  16. return $1 if $_ =~ /(.+?) (next|upcoming) (episode|airdate)/;
  17. return $1 if $_ =~ /when does (.+?) (season [0-9]+) (start|come out|air)/;
  18. return $1 if $_ =~ /when does (.+?) (start|come back|come out|air|return) ?(on)?/;
  19. return;
  20. };
  21. 1;