Library for scraping data from flow.polar.com.
First, login to flow.polar.com by using M-x scrape-flow-login
. This
asks for your login name and password and logs to flow.polar.com using
url.el
package. Your credentials won’t be saved. Your session lives
in the cookies url.el
uses.
After that you can use M-x scrape-flow-get-training
to produce an
completing-read
buffer which allows you to select the exercise you want to
fetch. By default this inserts the fetched object to the current
buffer. You can customize the action with
scrape-flow-get-training-action
. For example, my init.el
has the following:
(defun jogo3000/distance-to-string (distance)
"Convert DISTANCE in meters to readable string."
(-> (/ distance 1000) (number-to-string)))
(defun scrape-flow-to-org-item (training)
"Insert TRAINING as 'org-mode' item."
(org-insert-heading-respect-content)
(org-insert-property-drawer)
(org-entry-put (point) "AIKA"
(format-time-string "<%Y-%m-%d %a %H:%M>" (alist-get 'time training)))
(org-entry-put (point) "LAJI"
(cdr (assoc (alist-get 'sport training) scrape-flow-sports-translations)))
(-some->> (alist-get 'distance training) jogo3000/distance-to-string
(org-entry-put (point) "MATKA"))
(-some->> (alist-get 'duration training) (scrape-flow--seconds-to-string)
(org-entry-put (point) "KESTO"))
(-some->> (alist-get 'avg-hr training) (number-to-string)
(org-entry-put (point) "KESKISYKE"))
(-some->> (alist-get 'avg-pace training) (scrape-flow--pace-to-string)
(org-entry-put (point) "KESKIVAUHTI"))
(org-entry-put (point) "SRPE"
(completing-read "Arvioi SRPE: " '("1" "2" "3" "4" "5" "6" "7" "8" "9" "10")))
(org-entry-put (point) "KENKÄ"
(completing-read "Mitä kenkää käytit: "
(org-property-get-allowed-values (point) "KENKÄ")))
(org-entry-put (point) "ALUSTA"
(completing-read "Kuvaile harjoitusalusta: "
(org-property-get-allowed-values (point) "ALUSTA"))))
(setq scrape-flow-get-training-action 'scrape-flow-to-org-item)
Training data is gathered into an alist
with following structure
`((time . ,(scrape-flow--get-exercise-time dom)) ; emacs internal time
(sport . ,(scrape-flow--get-sport dom)) ; sport name as string
(duration . ,(scrape-flow--get-duration dom)) ; duration in seconds
(distance . ,(scrape-flow--get-distance dom)) ; distance in meters
(avg-hr . ,(scrape-flow--get-avg-hr dom)) ; average heart rate
(avg-pace . ,(scrape-flow--get-avg-pace dom)) ; average pace as seconds per kilometer
(ascent . ,(scrape-flow--get-ascent dom)) ; ascent in meters
(url . "https://flow.polar.com/training/analysis/495849359") ; link to the training details
)