PageRenderTime 37ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/duckduckgo/zeroclickinfo-spice
Perl | 55 lines | 43 code | 11 blank | 1 comment | 7 complexity | baa7011df4de37f46bf029c1149eb2d0 MD5 | raw file
Possible License(s): Apache-2.0
  1. package DDG::Spice::Guidebox::Getid;
  2. # ABSTRACT: Search for full free episodes of TV shows
  3. use strict;
  4. use DDG::Spice;
  5. primary_example_queries "guidebox Castle";
  6. description "Search for full free episodes of all your favorite TV shows (USA only)";
  7. name "Guidebox";
  8. code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/Guidebox/Getid.pm";
  9. icon_url "/i/www.guidebox.com.ico";
  10. topics "everyday", "entertainment", "social";
  11. category "entertainment";
  12. attribution github => ['https://github.com/adman','Adman'],
  13. twitter => ['http://twitter.com/adman_X','Adman'];
  14. triggers startend => "guidebox";
  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. my %skip = map { $_ => 0 } (
  18. 'watchmen',
  19. 'movie',
  20. 'movies',
  21. 'series',
  22. 'shows'
  23. );
  24. handle remainder => sub {
  25. if ($loc->country_name eq "United States" || $loc->country_name eq "Canada"){
  26. my $show = '';
  27. if ($_ =~ qr/^([\w\s]+)\s*?(?:episodes?)? online$/ ){
  28. $show = $1;
  29. } elsif ($_ =~ qr/^episodes? of ([\w\s]+)\s*?(?:\s*online)?$/){
  30. $show = $1;
  31. } elsif ($_ =~ qr/^([\w\s]+)\s*?episodes?$/){
  32. $show = $1;
  33. } elsif ($_ =~ qr/^([\w\s]+)\s*?series$/){
  34. $show = $1;
  35. } elsif ($_ =~ qr/^([\w\s]+)\s*?tv series$/){
  36. $show = $1;
  37. } else {
  38. $show = $_;
  39. }
  40. return $show if $show && !exists $skip{lc $show};
  41. }
  42. return;
  43. };
  44. 1;