[PATCH 2/2] Made emms-lastfm-submit-track resilient to BADSESSION

View: New views
1 Messages — Rating Filter:   Alert me  

[PATCH 2/2] Made emms-lastfm-submit-track resilient to BADSESSION

by Chris Gray-8 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The API says that on a BADSESSION response, the client should
re-handshake and re-submit the track.

Signed-off-by: Chris Gray <chrismgray@...>
---
 lisp/emms-lastfm.el |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/lisp/emms-lastfm.el b/lisp/emms-lastfm.el
index 028a221..d686cac 100644
--- a/lisp/emms-lastfm.el
+++ b/lisp/emms-lastfm.el
@@ -410,14 +410,18 @@ well or if an error occured."
     ;; response starts.
     (re-search-forward "^$" nil t)
     (forward-line)
-    (if (re-search-forward "^OK$" nil t)
-        (progn
-          (when emms-lastfm-submission-verbose-p
-            (message "EMMS: \"%s\" submitted to last.fm"
-                     (emms-track-description emms-lastfm-current-track)))
-          (kill-buffer buffer))
-      (message "EMMS: Song couldn't be submitted to last.fm: %s"
-               (emms-read-line)))))
+    (cond ((re-search-forward "^OK$" nil t)
+   (progn
+     (when emms-lastfm-submission-verbose-p
+       (message "EMMS: \"%s\" submitted to last.fm"
+ (emms-track-description emms-lastfm-current-track)))
+     (kill-buffer buffer)))
+  ((re-search-forward "^BADSESSION$" nil t)
+   (progn
+     (emms-lastfm-handshake)
+     (emms-lastfm-submit-track)))
+  (t (message "EMMS: Song couldn't be submitted to last.fm: %s"
+      (emms-read-line))))))
 
 ;;; Playback of lastfm:// streams
 
--
1.6.0.3.618.g55080




_______________________________________________
Emms-help mailing list
Emms-help@...
http://lists.gnu.org/mailman/listinfo/emms-help