aboutsummaryrefslogtreecommitdiff
path: root/emms-lastfm.el
diff options
context:
space:
mode:
authorWilliam Xu <william.xwl@gmail.com>2008-02-12 10:39:00 +0000
committerWilliam Xu <william.xwl@gmail.com>2008-02-12 10:39:00 +0000
commit535f7f7bf8ca34162b3ad854576d78ebf3ffb480 (patch)
treea649e8c90d60694532ab28d52e22696f40e39d2b /emms-lastfm.el
parenteb4229b372252d0e709760edcfc1ffe759367b70 (diff)
Resolve conflicts with Tassilo's repo.
darcs-hash:20080212103958-cfa61-4b529ef427982120e33ca7660dcfc3d3584f8196.gz
Diffstat (limited to 'emms-lastfm.el')
-rw-r--r--emms-lastfm.el72
1 files changed, 31 insertions, 41 deletions
diff --git a/emms-lastfm.el b/emms-lastfm.el
index 7735615..63e7497 100644
--- a/emms-lastfm.el
+++ b/emms-lastfm.el
@@ -204,25 +204,23 @@ These will be displayed on the user's last.fm page."
(musicbrainz-id "")
(track-length (number-to-string
(emms-track-get emms-lastfm-current-track
- 'info-playing-time)))
- (url-http-attempt-keepalives nil)
- (url-show-status emms-lastfm-submission-verbose-p)
- (url-request-method "POST")
- (url-request-extra-headers
- '(("Content-type" .
- "application/x-www-form-urlencoded; charset=utf-8")))
- (url-request-data
- (encode-coding-string
- (concat "&s=" emms-lastfm-session-id
- "&a[0]=" (emms-escape-url artist)
- "&t[0]=" (emms-escape-url title)
- "&b[0]=" (emms-escape-url album)
- "&l[0]=" track-length
- "&n[0]=" track-number
- "&m[0]=" musicbrainz-id)
- 'utf-8)))
- (url-retrieve emms-lastfm-now-playing-url
- 'emms-lastfm-submit-now-playing-sentinel)))
+ 'info-playing-time))))
+ ;; wait up to 5 seconds to submit np infos in order to finish handshaking.
+ (dotimes (i 5)
+ (when (not (and emms-lastfm-session-id
+ emms-lastfm-now-playing-url))
+ (sit-for 1)))
+ (when (and emms-lastfm-session-id
+ emms-lastfm-now-playing-url)
+ (emms-lastfm-http-POST emms-lastfm-now-playing-url
+ (concat "&s=" emms-lastfm-session-id
+ "&a[0]=" (emms-url-quote artist)
+ "&t[0]=" (emms-url-quote title)
+ "&b[0]=" (emms-url-quote album)
+ "&l[0]=" track-length
+ "&n[0]=" track-number
+ "&m[0]=" musicbrainz-id)
+ 'emms-lastfm-submit-now-playing-sentinel))))
(defun emms-lastfm-submit-now-playing-sentinel (&rest args)
"Parses the server reponse and inform the user if all worked
@@ -379,28 +377,20 @@ last.fm."
(musicbrainz-id "")
(track-length (number-to-string
(emms-track-get emms-lastfm-current-track
- 'info-playing-time)))
- (url-http-attempt-keepalives nil)
- (url-show-status emms-lastfm-submission-verbose-p)
- (url-request-method "POST")
- (url-request-extra-headers
- '(("Content-type" .
- "application/x-www-form-urlencoded; charset=utf-8")))
- (url-request-data
- (encode-coding-string
- (concat "&s=" emms-lastfm-session-id
- "&a[0]=" (emms-escape-url artist)
- "&t[0]=" (emms-escape-url title)
- "&i[0]=" emms-lastfm-current-track-starting-time-string
- "&o[0]=P" ;; TODO: Maybe support others. See the API.
- "&r[0]=" ;; The rating. Empty if not applicable (for P it's not)
- "&l[0]=" track-length
- "&b[0]=" (emms-escape-url album)
- "&n[0]=" track-number
- "&m[0]=" musicbrainz-id)
- 'utf-8)))
- (url-retrieve emms-lastfm-submit-url
- 'emms-lastfm-submission-sentinel)))
+ 'info-playing-time))))
+ (emms-lastfm-http-POST
+ emms-lastfm-submit-url
+ (concat "&s=" emms-lastfm-session-id
+ "&a[0]=" (emms-url-quote artist)
+ "&t[0]=" (emms-url-quote title)
+ "&i[0]=" emms-lastfm-current-track-starting-time-string
+ "&o[0]=P" ;; TODO: Maybe support others. See the API.
+ "&r[0]=" ;; The rating. Empty if not applicable (for P it's not)
+ "&l[0]=" track-length
+ "&b[0]=" (emms-url-quote album)
+ "&n[0]=" track-number
+ "&m[0]=" musicbrainz-id)
+ 'emms-lastfm-submission-sentinel)))
(defun emms-lastfm-submission-sentinel (&rest args)
"Parses the server reponse and inform the user if all worked