danielfm / smudge

Control the Spotify app from within Emacs.
https://asciinema.org/a/218654
GNU General Public License v3.0
309 stars 47 forks source link

Unable to load playlist or search for a track #61

Open dsylla opened 3 years ago

dsylla commented 3 years ago

Hello,

I'm having an issue during the connexion process

M-x spotify-my-playlist
M-x spotify-search-track
M-x spotify-select-playlist

I'm on MacOS Big Sur 11.1 with GNU Emacs 27.1

my config.el

(setq debug-on-error 1)
(add-load-path! "private/spotify-dot-el")
(require 'spotify)
(setq spotify-oauth2-client-id "********************"
      spotify-oauth2-client-secret "*****************")
(setq spotify-transport 'connect)
(define-key spotify-mode-map (kbd "C-c .") 'spotify-command-map)

This is the output I get after a while in *Backtrace*

Debugger entered--Lisp error: (wrong-type-argument hash-table-p nil)
  gethash(devices nil)
  (and t (gethash 'devices json))
  (let* ((devices (and t (gethash 'devices json)))) (if devices (while (let* ((device (car devices)) (is-active (spotify-get-device-is-active device))) (progn (if (and device is-active) (progn (progn ... ...))) (setq devices (cdr devices)) (and device (not is-active))))) nil))
  (closure (spotify-device-select-mode-abbrev-table spotify-device-select-mode-syntax-table t) (json) (let* ((devices (and t (gethash 'devices json)))) (if devices (while (let* ((device ...) (is-active ...)) (progn (if ... ...) (setq devices ...) (and device ...)))) nil)))(nil)
  funcall((closure (spotify-device-select-mode-abbrev-table spotify-device-select-mode-syntax-table t) (json) (let* ((devices (and t (gethash 'devices json)))) (if devices (while (let* ((device ...) (is-active ...)) (progn (if ... ...) (setq devices ...) (and device ...)))) nil))) nil)
  (progn (funcall callback nil))
  (if callback (progn (funcall callback nil)))
  (condition-case _ (if (search-forward-regexp "^$" nil t) (progn (let* ((json-object-type 'hash-table) (json-array-type 'list) (json-key-type 'symbol) (json (json-read)) (error-json (gethash 'error json))) (kill-buffer) (if (and (hash-table-p error-json) (eq 401 (gethash ... error-json)) (not is-retry)) (spotify-api-call-async method uri data callback t) (if callback (progn (funcall callback json))))))) (end-of-file (kill-buffer) (if callback (progn (funcall callback nil)))))
  (closure ((is-retry) (callback closure (spotify-device-select-mode-abbrev-table spotify-device-select-mode-syntax-table t) (json) (let* ((devices (and t ...))) (if devices (while (let* ... ...)) nil))) (data) (uri . "/me/player/devices") (method . "GET") t) (_) (toggle-enable-multibyte-characters t) (goto-char (point-min)) (condition-case _ (if (search-forward-regexp "^$" nil t) (progn (let* ((json-object-type ...) (json-array-type ...) (json-key-type ...) (json ...) (error-json ...)) (kill-buffer) (if (and ... ... ...) (spotify-api-call-async method uri data callback t) (if callback ...))))) (end-of-file (kill-buffer) (if callback (progn (funcall callback nil))))))((:error (error connection-failed "connect" :host "api.spotify.com" :service 443)))
  apply((closure ((is-retry) (callback closure (spotify-device-select-mode-abbrev-table spotify-device-select-mode-syntax-table t) (json) (let* ((devices (and t ...))) (if devices (while (let* ... ...)) nil))) (data) (uri . "/me/player/devices") (method . "GET") t) (_) (toggle-enable-multibyte-characters t) (goto-char (point-min)) (condition-case _ (if (search-forward-regexp "^$" nil t) (progn (let* ((json-object-type ...) (json-array-type ...) (json-key-type ...) (json ...) (error-json ...)) (kill-buffer) (if (and ... ... ...) (spotify-api-call-async method uri data callback t) (if callback ...))))) (end-of-file (kill-buffer) (if callback (progn (funcall callback nil)))))) (:error (error connection-failed "connect" :host "api.spotify.com" :service 443)))
  url-http-activate-callback()
  url-http-async-sentinel(#<process api.spotify.com<15>> "connect")

Thanks in advance

danielfm commented 3 years ago

Unfortunately I don't have access to a similar hardware and OS in order to debug this. Other people who do might be able to help.

elken commented 3 years ago

I'm having the same behaviour on Linux except I'm not getting a *Backtrace* it just silently fails. I can access my playlists fine so there's no auth issue.

EDIT: with debug-on-error on I also get a failure relating to /me/player/devices

EDIT 2: Managed to capture output from *URL-DEBUG* https://gist.github.com/elken/4df5a2dc38506ed0c2da7318018821e7

EDIT 3: It actually seems to fail on Spotify's end too :/ https://developer.spotify.com/console/get-user-player/ fails for me with an unfulfilled promise

EDIT 4: Issue located, if there is no applicable device to play music on, /me/player returns a 204 which should probably be handled

dsylla commented 3 years ago

Yes @elken I think the *Backtrace* buffer is from my "distribution" of Emacs (Doom Emacs).

Maybe the issue is not only from the package itself ... I'm not that good in Elisp so I'm not sure but from your output it seems like a there is also an issue with SSL ?

dsylla commented 3 years ago

UPDATE: I'm now able to load my playlists and a specific playlist but when I try to play a song nothing appends, and this time no error or trace whatsoever.

Nothing changed on my computer since my initial report. This leads me to think that maybe the issue is with Spotify API itself ...

elken commented 3 years ago

You have to have at least 1 device with Spotify open/able to stream to

jkdufair commented 3 years ago

Hi @dsylla -

I was getting this issue as well and have found some issues with Emacs' http request libraries. I've got a pull request submitted that uses request.el instead and it's behaving well. Maybe keep an eye on that and/or test it out?

jkdufair commented 3 years ago

@dsylla with the last PR merge, this issue should be resolved