From 535f7f7bf8ca34162b3ad854576d78ebf3ffb480 Mon Sep 17 00:00:00 2001 From: William Xu Date: Tue, 12 Feb 2008 10:39:00 +0000 Subject: Resolve conflicts with Tassilo's repo. darcs-hash:20080212103958-cfa61-4b529ef427982120e33ca7660dcfc3d3584f8196.gz --- emms-lastfm.el | 72 +++++++++++++++++++++++++--------------------------------- 1 file changed, 31 insertions(+), 41 deletions(-) (limited to 'emms-lastfm.el') 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 -- cgit v1.2.3