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

https://github.com/pardocz/zeroclickinfo-spice · Perl · 51 lines · 40 code · 11 blank · 0 comment · 6 complexity · 9bc275f4e81ac75f1c326d6250571348 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. my %skip = map { $_ => 0 } (
  18. 'watchmen'
  19. );
  20. handle remainder => sub {
  21. if ($loc->country_name eq "United States" || $loc->country_name eq "Canada"){
  22. my $show = '';
  23. if ($_ =~ qr/^([\w\s]+)\s*?(?:episodes?)? online$/ ){
  24. $show = $1;
  25. } elsif ($_ =~ qr/^episodes? of ([\w\s]+)\s*?(?:\s*online)?$/){
  26. $show = $1;
  27. } elsif ($_ =~ qr/^([\w\s]+)\s*?episodes?$/){
  28. $show = $1;
  29. } elsif ($_ =~ qr/^([\w\s]+)\s*?series$/){
  30. $show = $1;
  31. } elsif ($_ =~ qr/^([\w\s]+)\s*?tv series$/){
  32. $show = $1;
  33. } else {
  34. $show = $_;
  35. }
  36. return $show if $show && !exists $skip{lc $show};
  37. }
  38. return;
  39. };
  40. 1;