From 9dd55eed355f98f163dc45fc40f61ed9cb31da0e Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Tue, 16 Jan 2007 20:20:00 +0000 Subject: restart-lastfm-plugin-when-md5challenge-expired.dpatch darcs-hash:20070116202013-c06f4-ffed46f2b4507fd4aaf9d025efd052f8f169a7c0.gz --- emms-lastfm.el | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/emms-lastfm.el b/emms-lastfm.el index 1bb0b9a..bcf1c0f 100644 --- a/emms-lastfm.el +++ b/emms-lastfm.el @@ -209,6 +209,12 @@ the current track, too." (interactive) (emms-lastfm -1)) +(defun emms-lastfm-restart () + "Disable and reenable the last.fm plugin. This will cause a new +handshake." + (emms-lastfm-disable) + (emms-lastfm-enable)) + (defun emms-lastfm-handshake-if-needed () (when (not (and emms-lastfm-md5-challenge emms-lastfm-submit-url)) @@ -296,7 +302,12 @@ well or if an error occured." (message "EMMS: \"%s\" submitted to last.fm" (emms-track-description emms-lastfm-current-track)) (kill-buffer emms-lastfm-buffer)) - (message "EMMS: Song couldn't be submitted to last.fm")))) + (message "EMMS: Song couldn't be submitted to last.fm") + (goto-char (point-min)) + (when (re-search-forward "^BADAUTH$" nil t) + ;; Somehow our md5-challenge expired... + (message "EMMS: Restarting last.fm plugin") + (emms-lastfm-restart))))) ;;; Playback of lastfm:// streams @@ -309,9 +320,9 @@ well or if an error occured." (defcustom emms-player-lastfm-radio (emms-player 'emms-lastfm-radio-start 'ignore ; no need to stop 'emms-lastfm-radio-playable-p) - "*Parameters for the Last.fm radio player." - :type '(cons symbol alist) - :group 'emms-player-lastfm-radio) + "*Parameters for the Last.fm radio player." + :type '(cons symbol alist) + :group 'emms-player-lastfm-radio) (defconst emms-lastfm-radio-base-url "http://ws.audioscrobbler.com/radio/" "The base URL for playing lastfm:// stream. -- cgit v1.2.3