PageRenderTime 39ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/DDG/Spice/Tvmaze/Previousepisode.pm

http://github.com/duckduckgo/zeroclickinfo-spice
Perl | 28 lines | 16 code | 10 blank | 2 comment | 3 complexity | 3eaba4df948a83dceafbb0048de3f4fe MD5 | raw file
Possible License(s): Apache-2.0
  1. package DDG::Spice::Tvmaze::Previousepisode;
  2. # ABSTRACT: Information about the previous episode of TV series
  3. use strict;
  4. use DDG::Spice;
  5. # the previous 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. spice to => 'http://api.tvmaze.com/singlesearch/shows?q=$1&embed=previousepisode';
  10. spice wrap_jsonp_callback => 1;
  11. handle query_lc => sub {
  12. return unless $_;
  13. return $4 if $_ =~ /(previous|last|latest|recent) (episode|airdate) (in|of|for|from)? ?(.+)/;
  14. return $2 if $_ =~ /(previous|last|latest|recent) (.+?) episode/;
  15. return $1 if $_ =~ /(.+?) (previous|last|latest|recent) (episode|airdate)/;
  16. return;
  17. };
  18. 1;