Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no applicable method: counsel-spotify-do-play #13

Open
karthink opened this issue May 30, 2020 · 6 comments
Open

no applicable method: counsel-spotify-do-play #13

karthink opened this issue May 30, 2020 · 6 comments

Comments

@karthink
Copy link

All search commands (counsel-spotify-search-album, -track, -artist etc) are failing for me:

Contacting host: accounts.spotify.com:443
cl-no-applicable-method: No applicable method: counsel-spotify-do-play, #s(counsel-spotify-linux-backend #s(counsel-spotify-backend-commands "Play" "PlayPause" "Next" "Previous")), nil

The next/previous/play commands work fine.

My API client and secret are valid since I use them with another spotify client without issue. This is Emacs 27.0.90. I am trying with the official Linux spotify client open, although I would eventually like to use spotifyd.

This is my use-package declaration:

(use-package counsel-spotify
  :ensure
  :commands counsel-spotify-start-search
  :after counsel
  :general
  (:keymaps 'space-menu-map
    "U" '(counsel-spotify-start-search :wk "spotify"))
  :config
  (defun counsel-spotify-start-search ()
    (interactive)
    (counsel-M-x "counsel-spotify-search-"))
  (setq counsel-spotify-service-name "spotify")
  (setq counsel-spotify-client-id my-counsel-spotify-client-id
        counsel-spotify-client-secret my-counsel-spotify-client-secret
        counsel-spotify-use-notifications nil))

The my-counsel-spotify- variables are set elsewhere.

@Lautaro-Garcia
Copy link
Owner

Hello! It seems somehow related with issue #12, the error seems to be the same.

The offending function is counsel-spotify-do-play as it was asked to play nil (this is what I can interpret from the error above).
My question to you is, are you able to see the list of results, or the error pops up before you can even see them? Because that function only gets called when you actually want to play a thing (a song, an album, an artist or a playlist).

I'm worried that, in a way, the Spotify API response has changed somehting slightly and counsel-spotify isn't able to parse it quite right, so it ends up with a nil as a thing to play.
Another thing that could have changed is ivy, and the selection of an item is returning an empty thing, could you tell me what version of ivy are you currently using?

Thank you!

@karthink
Copy link
Author

karthink commented May 31, 2020 via email

@Lautaro-Garcia
Copy link
Owner

Sorry fo the delay, I can't seem to reproduce this case.
I am looking at the code back and forth, but am not seeing a place where the function counsel-spotify-do-play is called before an ivy action is fired up.

Reading your issue description again, I noticed that I'm running an older version of Emacs (everything else is the same, I'm assuming you have the latest version of counsel-spotify). I will try this updating Emacs to see if I can reproduce this bug.

A quick hack you could use, as I keep in my quest of finding this bug is actually defining a method for nil that does nothing

(cl-defmethod counsel-spotify-do-play ((backend counsel-spotify-linux-backend) (something (eql nil)))
  nil)

at least with this defined you'll be able to keep using counsel-spotify in the meantime.

Thank you for your patience!

@SnootierMoon
Copy link

SnootierMoon commented Aug 6, 2020

Hi, I'm new to Github and Emacs so let me know if I'm doing anything wrong by posting this here.

I was running in to a similar error, and I managed to fix it.

I found out that the program was failing to authenticate in the first url-retrieve call. After doing a bit of debugging, I realized that the counsel-spotify-basic-auth-credentials call in counsel-spotify-with-auth-token wasn't updating after I set the client ID and secret. Since the authentication doesn't work, everything would break, and I would get 0 results in the search buffer. When I press enter, I would get the cl-no-applicable-method error. However, when I remove the comma that comes before it, the entire thing works perfectly.

Is there any reason why the comma is there? As I understand it, removing the comma will just mean that counsel-spotify-basic-auth-credentials gets called again every time the counsel-spotify-with-auth-token macro is called. To be honest, I don't really understand how this kind of macro works, but removing the comma seems to work for me.

Thanks a lot for this plugin btw, I really love it :)

@Lautaro-Garcia
Copy link
Owner

Oh, you're totally right!
The credentials were loaded on macro-expansion time and then counsel-spotify would no longer update them! Thank you for taking the time to debug this. I'll try to replicate the case that you're mentioning, commit the fix that you're proposing and hopefully have a version with this fix on MELPA in a couple of days.

PS: You did everything right, thank you very much!

@Lautaro-Garcia
Copy link
Owner

Well, yesterday I uploaded a new version with the change that you proposed, please tell me if the issue you were mentioning is fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants