/lib/DDG/Spice/Movie.pm
https://github.com/pardocz/zeroclickinfo-spice · Perl · 37 lines · 22 code · 7 blank · 8 comment · 1 complexity · df14c3a84c2980080a53e760e8574ed7 MD5 · raw file
- package DDG::Spice::Movie;
- use DDG::Spice;
- primary_example_queries "the graduate movie";
- secondary_example_queries "jiro dreams of sushi rating", "indie game film";
- description "Movie information from Rotten Tomatoes";
- name "Movie";
- code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/Movie.pm";
- icon_url "/i/www.rottentomatoes.com.ico";
- topics "entertainment", "everyday";
- category "entertainment";
- attribution github => ['https://github.com/moollaza','Zaahir Moolla'],
- twitter => ['https://twitter.com/zmoolla','zmoolla'];
- spice proxy_cache_valid => "200 7d";
- spice to => 'http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey={{ENV{DDG_SPICE_ROTTEN_APIKEY}}}&q=$1&page_limit=50&page=1&callback={{callback}}';
- # It's important that 'movie info' precede 'movie' so that the handler
- # encounters it first and removes both words, rather than encountering 'movie'
- # first in the list, removing it, and leaving the word 'info.'
- # This spice will usually be triggered by deep triggers,
- # with a few extra triggers that deep might miss.
- my @triggers = ( 'rotten tomatoes', 'rotten');
- triggers startend => @triggers;
- handle query_lc => sub {
- # spice triggers are called when a trigger is part of a hyphenated word
- # i.e.: asus rt-66nu
- # this makes sure that only space deliminated words fire this spice
- my $input = $_;
- map { return $input if $input =~ s/(^|\s)$_(\s|$)// and $input ne '' } @triggers;
- return;
- };
- 1;