/lib/DDG/Spice/GetEvents.pm
Perl | 29 lines | 20 code | 6 blank | 3 comment | 3 complexity | d0671fe3f07d37d537076117bf5f58a3 MD5 | raw file
Possible License(s): Apache-2.0
- package DDG::Spice::GetEvents;
- #ABSTRACT: Returns events near the user's location.
- use DDG::Spice;
- primary_example_queries "events near me";
- description "Upcoming events from GetEvents";
- code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/GetEvents.pm";
- category "entertainment";
- topics "computing","entertainment","food_and_drink","music","science","special_interest","travel";
- triggers startend => 'events near me', 'nearby events';
- spice to => 'https://api.getevents.co/ddg?lat=$1&lng=$2&timezone=$3' ;
- # 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 '/'.
- spice from => '([^/]+)/([^/]+)/(.*)';
- spice wrap_jsonp_callback => 1;
- spice is_cached => 1;
- handle remainder => sub {
- # Verifying that $loc and the relevant geo attributes (longitude and latitude) are valid.
- return unless $loc && $loc->longitude && $loc->latitude && $loc->time_zone;
- my $lng = $loc->longitude;
- my $lat = $loc->latitude;
- my $tz = $loc->time_zone;
- return $lat, $lng, $tz;
- };
- 1;