]> git.donarmstrong.com Git - lib.git/blobdiff - emacs_el/google-weather.el
update google weather
[lib.git] / emacs_el / google-weather.el
index 54fe506df4f4ea1913b4637218e8a420774c8751..be09e34cc4ed2a92d13fce8ee9ac4056cbc29814 100644 (file)
   "Google Weather."
   :group 'comm)
 
+(defcustom google-weather-use-https t
+  "Default protocol to use to access the Google Weather API."
+  :group 'google-weather)
+
 (defconst google-weather-url
-  "http://www.google.com/ig/api"
+  "www.google.com/ig/api"
   "URL of the Google Weather API.")
 
 (defconst google-weather-image-url
@@ -86,7 +90,8 @@ to 0 force a cache renewal."
          data)
     (with-current-buffer buffer
       (goto-char (point-min))
-      (search-forward "\n\n")
+      (unless (search-forward "\n\n" nil t)
+        (error "Data not found"))
       (decode-coding-region
        (point) (point-max)
        (detect-coding-region (point) (point-max) t))
@@ -99,7 +104,7 @@ to 0 force a cache renewal."
 
 (defun google-weather-build-url (location &optional language)
   "Build URL to retrieve weather for LOCATION in LANGUAGE."
-  (concat google-weather-url "?weather=" (url-hexify-string location)
+  (concat "http" (when google-weather-use-https "s") "://" google-weather-url "?weather=" (url-hexify-string location)
           (when language
             (concat "&hl=" language))))