PageRenderTime 36ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/DDG/Spice/GetEvents.pm

http://github.com/duckduckgo/zeroclickinfo-spice
Perl | 29 lines | 20 code | 6 blank | 3 comment | 3 complexity | d0671fe3f07d37d537076117bf5f58a3 MD5 | raw file
Possible License(s): Apache-2.0
  1. package DDG::Spice::GetEvents;
  2. #ABSTRACT: Returns events near the user's location.
  3. use DDG::Spice;
  4. primary_example_queries "events near me";
  5. description "Upcoming events from GetEvents";
  6. code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/GetEvents.pm";
  7. category "entertainment";
  8. topics "computing","entertainment","food_and_drink","music","science","special_interest","travel";
  9. triggers startend => 'events near me', 'nearby events';
  10. spice to => 'https://api.getevents.co/ddg?lat=$1&lng=$2&timezone=$3' ;
  11. # Extract the geo location from the result returned by the handler: two real numbers seperated by '/' and after them a time zone also seperated by a '/'.
  12. spice from => '([^/]+)/([^/]+)/(.*)';
  13. spice wrap_jsonp_callback => 1;
  14. spice is_cached => 1;
  15. handle remainder => sub {
  16. # Verifying that $loc and the relevant geo attributes (longitude and latitude) are valid.
  17. return unless $loc && $loc->longitude && $loc->latitude && $loc->time_zone;
  18. my $lng = $loc->longitude;
  19. my $lat = $loc->latitude;
  20. my $tz = $loc->time_zone;
  21. return $lat, $lng, $tz;
  22. };
  23. 1;