PageRenderTime 43ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/DDG/Spice/Guidebox/Getid.pm

https://github.com/robertbrook/zeroclickinfo-spice
Perl | 46 lines | 37 code | 9 blank | 0 comment | 6 complexity | f028da0ead713b3f99c468e301c6c753 MD5 | raw file
  1. package DDG::Spice::Guidebox::Getid;
  2. use DDG::Spice;
  3. primary_example_queries "guidebox Castle";
  4. description "Search for full free episodes of all your favorite TV shows (USA only)";
  5. name "Guidebox";
  6. code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/Guidebox/Getid.pm";
  7. icon_url "/i/www.guidebox.com.ico";
  8. topics "everyday", "entertainment", "social";
  9. category "entertainment";
  10. attribution github => ['https://github.com/adman','Adman'],
  11. twitter => ['http://twitter.com/adman_X','adman_X'];
  12. triggers startend => "guidebox";
  13. triggers start => "watch", "stream", "full episodes of", "full free episodes of", "free episodes of", "episodes of", "where to watch";
  14. triggers any => "full episodes", "watch free", "full free episodes", "free episodes", "episodes", "recent episodes";
  15. spice to => 'http://api-public.guidebox.com/v1.3/json/{{ENV{DDG_SPICE_GUIDEBOX_APIKEY}}}/search/title/$1';
  16. spice wrap_jsonp_callback => 1;
  17. handle remainder => sub {
  18. if ($loc->country_name eq "United States" || $loc->country_name eq "Canada"){
  19. my $show = '';
  20. if ($_ =~ qr/^([\w\s]+)\s*?(?:episodes?)? online$/ ){
  21. $show = $1;
  22. } elsif ($_ =~ qr/^episodes? of ([\w\s]+)\s*?(?:\s*online)?$/){
  23. $show = $1;
  24. } elsif ($_ =~ qr/^([\w\s]+)\s*?episodes?$/){
  25. $show = $1;
  26. } elsif ($_ =~ qr/^([\w\s]+)\s*?series$/){
  27. $show = $1;
  28. } elsif ($_ =~ qr/^([\w\s]+)\s*?tv series$/){
  29. $show = $1;
  30. } else {
  31. $show = $_;
  32. }
  33. return $show if $show;
  34. }
  35. return;
  36. };
  37. 1;