|
@@ -4,15 +4,20 @@
|
|
|
(defparameter +forecast-api-url+ "https://api.forecast.io/forecast" "forecast.io API endpoint")
|
|
(defparameter +forecast-api-url+ "https://api.forecast.io/forecast" "forecast.io API endpoint")
|
|
|
|
|
|
|
|
(defun forecast (lat lon &key time (currently t) minutely hourly daily alerts)
|
|
(defun forecast (lat lon &key time (currently t) minutely hourly daily alerts)
|
|
|
- (yason:parse
|
|
|
|
|
- (flexi-streams:octets-to-string
|
|
|
|
|
- (drakma:http-request (format
|
|
|
|
|
- nil
|
|
|
|
|
- "~A/~A/~A,~A~@[,~A~]?units=si&exclude=~:[currently,~;~]~:[minutely,~;~]~:[hourly,~;~]~:[daily,~;~]~:[alerts,~;~]flags&lang=ru"
|
|
|
|
|
- +forecast-api-url+ *forecast-api-key* lat lon time
|
|
|
|
|
- currently minutely hourly daily alerts))
|
|
|
|
|
- :external-format :utf8)
|
|
|
|
|
- :object-as :alist))
|
|
|
|
|
|
|
+ (handler-case
|
|
|
|
|
+ (bordeaux-threads:with-timeout (5)
|
|
|
|
|
+ (yason:parse
|
|
|
|
|
+ (flexi-streams:octets-to-string
|
|
|
|
|
+ (drakma:http-request (format
|
|
|
|
|
+ nil
|
|
|
|
|
+ "~A/~A/~A,~A~@[,~A~]?units=si&exclude=~:[currently,~;~]~:[minutely,~;~]~:[hourly,~;~]~:[daily,~;~]~:[alerts,~;~]flags&lang=ru"
|
|
|
|
|
+ +forecast-api-url+ *forecast-api-key* lat lon time
|
|
|
|
|
+ currently minutely hourly daily alerts))
|
|
|
|
|
+ :external-format :utf8)
|
|
|
|
|
+ :object-as :alist))
|
|
|
|
|
+ (bordeaux-threads:timeout (e)
|
|
|
|
|
+ (declare (ignore e))
|
|
|
|
|
+ (error "Timeout"))))
|
|
|
|
|
|
|
|
(local-time:reread-timezone-repository :timezone-repository "/usr/share/zoneinfo/")
|
|
(local-time:reread-timezone-repository :timezone-repository "/usr/share/zoneinfo/")
|
|
|
|
|
|