PageRenderTime 53ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/DDG/Spice/BoardGameGeek/Search.pm

http://github.com/duckduckgo/zeroclickinfo-spice
Perl | 32 lines | 21 code | 9 blank | 2 comment | 0 complexity | e80e21f2b6606c48e509b3a7909f4ea4 MD5 | raw file
Possible License(s): Apache-2.0
  1. package DDG::Spice::BoardGameGeek::Search;
  2. # ABSTRACT: Get information on a board game from the BoardGameGeek API
  3. use DDG::Spice;
  4. spice is_cached => 1;
  5. spice proxy_cache_valid => "200 7d";
  6. spice wrap_jsonp_callback => 1;
  7. # Need to escape string passed to &u= param, except $1
  8. my $search_url = uri_esc("http://www.boardgamegeek.com/xmlapi2/search?type=boardgame&query=");
  9. my $detail_url = uri_esc("http://www.boardgamegeek.com/xmlapi2/thing?stats=1&id=");
  10. spice to => 'https://duckduckgo.com/x.js?u=' . $search_url . '$1';
  11. spice alt_to => {
  12. get_details => {
  13. to => 'https://duckduckgo.com/x.js?u=' . $detail_url . '$1',
  14. is_cached => 1,
  15. proxy_cache_valid => "200 14d"
  16. }
  17. };
  18. triggers end => 'boardgamegeek', 'board game geek', 'boardgame', 'board game', 'card game', 'bgg';
  19. handle remainder => sub {
  20. return unless $_;
  21. return $_;
  22. };
  23. 1;