Closed eklebanow closed 3 years ago
What is the lastfm status on that call/link? You can open the audioscrobbler page that you've given above to check it (I get a lfm status="ok" on your link), but I did catch lastfm down a few times in the past.
You've copy/pasted you api_key here in the open. I think that that should remain private?!
Let me know.
So what do I try next to get vuiet working. I too get status ok from the link
I haven't changed anything to vuiet
lately, as you can see.
Any luck?
I am going back and forth with last fm support... Getting same error on laptops that I have ... Support asked if it could be you tube api or they said to contact you about vuiet api.. I responded that I have my own api. They asked for my API key. I will keep you posted
Get Outlook for Androidhttps://aka.ms/AAb9ysg
From: Mihai Olteanu @.> Sent: Tuesday, October 12, 2021 12:46:55 AM To: mihaiolteanu/vuiet @.> Cc: eklebanow @.>; Author @.> Subject: Re: [mihaiolteanu/vuiet] Unable to start Vuiet (#64)
Any luck?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/mihaiolteanu/vuiet/issues/64#issuecomment-940752722, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIDY2CGXISOJ3SB5VLCJ2MLUGPRW7ANCNFSM5FSGFKIA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Hi there, Ben from Last.fm here.
You're most likely getting the error because you're missing Content-Length:
header on your POST requests (as that is what 411: Length-required
implies). We recently updated our API web server software and this may be an unexpected side-effect.
Whilst I'm looking at if there's a path further forward which relaxes this requirement, you should include Content-Length header in your POST requests anyway.
FYI @mihaiolteanu I reckon the bug is most likely at this line https://github.com/mihaiolteanu/lastfm.el/blob/276c30a16518e545c95b7d693bada3ec01ddd207/lastfm.el#L516
You explicitly set the curl option -d ""
- that is, "no body data" - and that will instruct curl to send Content-Length: 0
, which is not true when you're POSTing form data
Hello Ben, Thanks for reaching out!
My request parameters for a track search with name "my",
(("api_key"`` . "my-api-key(removed)")
("method" . "track.search")
("track" . "my")
("limit" . 10)
("page" . 1))
This is the reply from lastfm with the above parameters (lastfm--request
does the calling, as you've correctly hinted above),
<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<lfm status=\"ok\"><results><opensearch:Query role=\"request\" startPage=\"1\"></opensearch:Query>
<opensearch:totalResults>14626696</opensearch:totalResults>
<opensearch:startIndex>0</opensearch:startIndex>
<opensearch:itemsPerPage>10</opensearch:itemsPerPage>
<trackmatches><track><name>My Time</name>
<artist>BTS</artist>
<url>https://www.last.fm/music/BTS/_/My+Time</url>
<streamable>FIXME</streamable>
<listeners>166609</listeners>
<image size=\"small\">https://lastfm.freetls.fastly.net/i/u/34s/2a96cbd8b46e442fc41c2b86b821562f.png</image>
<image size=\"medium\">https://lastfm.freetls.fastly.net/i/u/64s/2a96cbd8b46e442fc41c2b86b821562f.png</image>
<image size=\"large\">https://lastfm.freetls.fastly.net/i/u/174s/2a96cbd8b46e442fc41c2b86b821562f.png</image>
<image size=\"extralarge\">https://lastfm.freetls.fastly.net/i/u/300x300/2a96cbd8b46e442fc41c2b86b821562f.png</image>
<mbid></mbid>
</track>
<track><name>My Universe</name>
<artist>Coldplay</artist>
<url>https://www.last.fm/music/Coldplay/_/My+Universe</url>
<streamable>FIXME</streamable>
<listeners>141832</listeners>
<image size=\"small\">https://lastfm.freetls.fastly.net/i/u/34s/2a96cbd8b46e442fc41c2b86b821562f.png</image>
<image size=\"medium\">https://lastfm.freetls.fastly.net/i/u/64s/2a96cbd8b46e442fc41c2b86b821562f.png</image>
<image size=\"large\">https://lastfm.freetls.fastly.net/i/u/174s/2a96cbd8b46e442fc41c2b86b821562f.png</image>
<image size=\"extralarge\">https://lastfm.freetls.fastly.net/i/u/300x300/2a96cbd8b46e442fc41c2b86b821562f.png</image>
<mbid></mbid>
</track>
<track><name>Fly To My Room</name>
<artist>BTS</artist>
<url>https://www.last.fm/music/BTS/_/Fly+To+My+Room</url>
<streamable>FIXME</streamable>
<listeners>147928</listeners>
<image size=\"small\">https://lastfm.freetls.fastly.net/i/u/34s/2a96cbd8b46e442fc41c2b86b821562f.png</image>
<image size=\"medium\">https://lastfm.freetls.fastly.net/i/u/64s/2a96cbd8b46e442fc41c2b86b821562f.png</image>
<image size=\"large\">https://lastfm.freetls.fastly.net/i/u/174s/2a96cbd8b46e442fc41c2b86b821562f.png</image>
<image size=\"extralarge\">https://lastfm.freetls.fastly.net/i/u/300x300/2a96cbd8b46e442fc41c2b86b821562f.png</image>
<mbid></mbid>
</track>
....(the rest of the tracks follow)....
</trackmatches>
</results>
</lfm>
I can confirm that I have no problem getting the info from lastfm, nor of using vuiet, in general. This one works for me, for example,
(lastfm-artist-get-info "anathema")
@eklebanow please check the lastfm reply to an lastfm-artist-get-info
, for example.
Please use edebug, as suggested above to check the reply from lastfm to your requests.
Please add the suggestions from Ben and check if that solves your problem.
Mihai
@eklebanow or, without edebug, go to lastfm--request
and modify it so that you setf some global variables of your choice to
(lastfm--build-params method auth params values)
and
to to the data
inside this function, respectively
(cl-function
(lambda (&key data &allow-other-keys)
(setq resp data)))
Post that online, then. Maybe there is something interesting in there.
@mihaiolteanu i note that request.el uses curl
, which of course is a command line package installed on your system. If you can get it to spit out the full curl
command that is actually issued for POST requests, that would be helpful, but as I say, I suspect the extra parameter -d ""
(as linked in my previous comments) to be the cause of the problem
Also note that it's not recommended to use POST for methods like artist.getInfo. GET will do just fine, and also the content length isn't an issue when you're using query string parameters.
it would be an issue for scrobbling, which should still be done with a POST.
Subject: vuiet not being able to start Date: Thu, 14 Oct 2021 17:43:40 -0700
Mihai,
I am relatively new to computer code and emacs. Based on the chain of emails which I see between you and Ben you asked if I could change something about the following function in lastfm.el:
(defun lastfm--request (method auth params &rest values) "Send and return the Last.fm request for METHOD. AUTH, PARAMS and VALUES are only passed allong to 'lastfm--build-params'. See the documentation for that method." (let (resp (request-curl-options '("-d" ""))) (request lastfm--url :params (lastfm--build-params method auth params values) :parser 'buffer-string :type "POST" :sync t :complete (cl-function (lambda (&key data &allow-other-keys) (setq resp data))))
What exactly do you want me to change and once I change it what should I do (i.e try to run vuiet?) and what you want me to send to you...
-- Edward R. Klebanow, DVM 8201 W Olive Ave #1062 Peoria AZ 85345 @.*** 480 250-6364
@eklebanow just use this function, as suggested by Ben, and see if that fixes your issue,
(defun lastfm--request (method auth params &rest values)
"Send and return the Last.fm request for METHOD.
AUTH, PARAMS and VALUES are only passed allong to
'lastfm--build-params'. See the documentation for that method."
(let (resp)
(request lastfm--url
:params (lastfm--build-params method auth params values)
:parser 'buffer-string
:type "POST"
:sync t
:complete (cl-function
(lambda (&key data &allow-other-keys)
(setq resp data))))
resp))
That is, go to your location of lastfm.el, locate your lastfm--request
function and change it to this one (don't forget to reload/restart your Emacs).
Or, much easier, copy/paste the above function in your scratch buffer, evaluate it (C-x C-e) and try to see if you can reproduce your bug after that.
@aluaces Can you also check? I believe you've introduced this change, https://github.com/mihaiolteanu/lastfm.el/commit/00724f755394940c58a8f8af5e27cc202b5170f0#diff-3f23f57ce437aaa2ee1073acf3e7810d70dba3c27f20f1cf81865e79cfe6bd4b
@ben-xo
You explicitly set the curl option
-d ""
- that is, "no body data" - and that will instruct curl to sendContent-Length: 0
, which is not true when you're POSTing form data
My man page for curl
says,
-d, --data <data>
(HTTP) Sends the specified data in a POST request to the HTTP
server, in the same way that a browser does when a user has
filled in an HTML form and presses the submit button. This will
cause curl to pass the data to the server using the content-type
application/x-www-form-urlencoded. Compare to -F, --form.
Is this the same as you're implying?
@ben-xo @eklebanow
You are right. My vuiet
was a bit behind (for some reason) and I did not have the "-d " option that Ben is referring to.
With this option I, indeed, also receive an error and vuiet
is "unable to start", as Edward reports.
Hi, the point of using -d ""
was because the request was failing since no Content-Length
was sent, and lastfm was rejecting it.
I'm a bit perplexed since I'm using that right now, and it's working. Maybe the change lies in what curl sends, my version is 7.74.0
Maybe the best way to tackle this problem is what Ben says, just issue a GET request, otherwise we must compute the correct length and send it, something that didn't seem straightforward to me.
@ben-xo
Here are the parameters used by curl
for a lastfm request (including the "-d" option)
("curl" "--silent" "--location"
"--cookie" "/home/mihai/.emacs.d/request/curl-cookie-jar" "--cookie-jar"
"/home/mihai/.emacs.d/request/curl-cookie-jar" "--include" "--write-out"
"\\n(:num-redirects %{num_redirects} :url-effective \"%{url_effective}\")"
"-d" "" "--compressed" "--request" "POST"
"http://ws.audioscrobbler.com/2.0/?api_key=[....]&method=track.search&track=whatever&limit=10&page=1")
@aluaces So you are saying the exact opposite that Ben is saying :) For us, it seems it is not working, sadly. I'm having curl 7.64.0.
@aluaces So you are saying the exact opposite that Ben is saying :) For us, it seems it is not working, sadly. I'm having curl 7.64.0.
I don't disagree with him, in fact I acknowledge the fact that Content-Lenght
is required. In my experience setting ""
works, but I also agree with him about the right thing to do is pass the actual length.
I have yet to find if my curl auto-computes that value or if it just sends 0
.
I have checked and it just sends 0
:
This is the output of curl --request POST -v 'https://example.com/api?param=1¶m2=2'
POST /api?param=1¶m2=2 HTTP/2 Host: example.com user-agent: curl/7.74.0 accept: / content-length: 0 content-type: application/x-www-form-urlencoded
But thinking about it, the correct value is 0
, since the body is empty, or am I wrong?
Well, I'm getting a different output to the same command you've posted,
> POST /api?param=1¶m2=2 HTTP/2
> Host: example.com
> User-Agent: curl/7.64.0
> Accept: */*
>
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
* Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
< HTTP/2 411
< content-type: text/html
< date: Fri, 15 Oct 2021 10:26:57 GMT
< server: ECS (dcb/7FA4)
< content-length: 357
<
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>411 - Length Required</title>
</head>
<body>
<h1>411 - Length Required</h1>
</body>
</html>
The 411 is the "peculiar error" that @eklebanow has posted initially,
[error] request--callback: peculiar error: 411
So then, for that curl version -d ""
does nothing, since it doesn't set content-length
.
But on the other hand, it is required by lastfm.
I suppose that if you don't use -d ""
content-length
is still not computed, or is it?
I suppose that if you don't use
-d ""
content-length
is still not computed, or is it?
Don't use "-d" where? In the lastfm call in emacs lisp, or on the command line? Though I'm not seeing it on the command line example from above.
You are right, sorry. I tried both
curl --request POST -d "" -v 'https://example.com/api?param=1¶m2=2'
and
curl --request POST -v 'https://example.com/api?param=1¶m2=2'
The first gets the header set, the second doesn't.
Trying the first one, then...
$ curl --request POST -d "" -v 'https://example.com/api?param=1¶m2=2'
< HTTP/2 404
< cache-control: max-age=604800
< content-type: text/html; charset=UTF-8
< date: Fri, 15 Oct 2021 10:43:08 GMT
< expires: Fri, 22 Oct 2021 10:43:08 GMT
< server: EOS (vny/0451)
< content-length: 445
* HTTP error before end of send, stop sending
<
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>404 - Not Found</title>
</head>
<body>
<h1>404 - Not Found</h1>
<script type="text/javascript" src="//wpc.75674.betacdn.net/0075674/www/ec_tpm_bcon.js"></script>
</body>
</html>
Ok, but you want the lines marked with >
, that are your request, instead of the ones prepended with <
, that are the response.
Ok, so both of them again,
$ curl --request POST -d "" -v 'https://example.com/api?param=1¶m2=2'
> POST /api?param=1¶m2=2 HTTP/2
> Host: example.com
> User-Agent: curl/7.64.0
> Accept: */*
> Content-Length: 0
> Content-Type: application/x-www-form-urlencoded
>
$curl --request POST -v 'https://example.com/api?param=1¶m2=2'
> POST /api?param=1¶m2=2 HTTP/2
> Host: example.com
> User-Agent: curl/7.64.0
> Accept: */*
>
I don't even get a Content-Length in the second case, as you do. Anyway, I, for one, am still not closer to a solution. What I do get is an error, as reported by OP, with the "-d" parameter set and no error without it.
Ok, so curl is behaving identically.
So I don't know why it's working for you without -d""
. If I take it out, vuiet does not work for me, and that might be related to what Ben says about them rejecting requests without content-length
header.
Take it out if you wish, I don't mind manually patching my version if I'm the only one with this problem :smile:
@ben-xo @eklebanow You are right. My
vuiet
was a bit behind (for some reason) and I did not have the "-d " option that Ben is referring to. With this option I, indeed, also receive an error andvuiet
is "unable to start", as Edward reports.
Thanks for posting the full curl line, so I can test that too.
I have confirmed that on my local setup,
--request POST
with -d ""
works--request POST
without -d ""
does not work--request GET
without -d ""
works(I still think you should be using GET for this type of request).
It appears I was wrong about -d ""
being present causing an issue - it seemed it was the fact it was missing.
In any case, if you want curl
to automatically generate the Content-Length
for you, it's quite simple: pass your data to curl, instead of including it in the URL.
So take the following example:
curl --request POST -d "" -v 'https://example.com/api?param=1¶m2=2'
If you reformulate this into
curl --request POST -d 'param=1' -d 'param2=2' -v 'https://example.com/api'
you will get the following:
> POST /api HTTP/2
> Host: example.com
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Length: 16
> Content-Type: application/x-www-form-urlencoded
>
…
that is, the correct content-type and the correct content-length are automatically generated for you just by using the curl -d
option properly.
Nonetheless, you should use GET
(and https!) for the requests you are making, except scrobbles, which need to be POST
If I replace the function with the one you provided:
(defun lastfm--request (method auth params &rest values) "Send and return the Last.fm request for METHOD. AUTH, PARAMS and VALUES are only passed allong to 'lastfm--build-params'. See the documentation for that method." (let (resp) (request lastfm--url :params (lastfm--build-params method auth params values) :parser 'buffer-string :type "POST" :sync t :complete (cl-function (lambda (&key data &allow-other-keys) (setq resp data)))) resp))
I still get the same error:
iiConfig successfully reloaded! Play random? (y or n) y [error] request--callback: peculiar error: 411 [error] request-default-error-callback: http://ws.audioscrobbler.com/2.0/?api_key=484d911a7d634cbcc5146b7492522eaf&method=user.getLovedTracks&user=klebane&limit=500&page=1 error user-error: Minibuffer window is not active
If I paste the function that you provided into the scratch buffer and evaluate it in the minibuffer I do not get the error. In the minbuffer it states lastfm--request
I have curl 7.79.1 on my gentoo box.
If I do the following curl from the cli I get the (>Content-Length: 445)
curl --request POST -d 'param=1' -d 'param2=2' -v 'https://example.com/api'
here is pastebin of the above command: http://dpaste.com/2C6ASRSDR
If I evaluate lastfm get info
beatles
I get:
`[error] request-default-error-callback: http://ws.audioscrobbler.com/2.0/?api_key=484d911a7d634cbcc5146b7492522eaf&method=artist.getTopTracks&artist=beatles&limit=15&page=1 error seq-subseq: Bad bounding indices: 3, 7
`
that is, the correct content-type and the correct content-length are automatically generated for you just by using the curl
-d
option properly.
This would then look to me like an error in the request.el package itself.
That is, you are not able to pass the parameters to the request call, as specified in its API, but must use the request-curl-options
to pass all the parameters. Something is not quite right here, in my mind.
@tkf? (the offending code, for quick reference)
Nonetheless, you should use
GET
(and https!) for the requests you are making, except scrobbles, which need to be POST
...and any methods that require authentication, like love/unlove track, I assume. I will try that.
This would then look to me like an error in the request.el package itself.
I think request.el is fine, but we are not using it correctly, since the parameters in a POST request are passed via the :data
field, not directly in the URL as GET: https://github.com/tkf/emacs-request#examples
but we are not using it correctly
...or that! :)) Good catch! I think I was too lazy initially to have two implementations for the request functionality and I've crammed everything into a single request with a POST method, since that seemed to work in all cases (GET methods included). Until it doesn't work anymore.
Splitting lastfm--request
into two functions, one for POST one for GET and replacing the lastfm--request
itself with code for selecting from the two based on the auth
method ("yes" for scrobble, love/unlove track and "no" for everything else), should fix the above laziness.
Ok, I've pushed the temp solution to the post-get-request-split branch.
GET works (top-tracks, artist-info, etc) but POST (track-love, scrobble) fails with,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<lfm status=\"failed\">
<error code=\"9\">Invalid session key - Please re-authenticate</error>
</lfm>
I've checked the data
and it contains the api_key, secret_key and the api_signature, as before.
I haven't changed the code that handles that part.
Any hints? Did I miss something?
Mihai,.
I do not understand your response. Did you fix the issue? Is there something wrong with my authentication?
What should I do?
Get Outlook for Androidhttps://aka.ms/AAb9ysg
From: Mihai Olteanu @.> Sent: Monday, October 18, 2021 1:59:00 AM To: mihaiolteanu/vuiet @.> Cc: eklebanow @.>; Mention @.> Subject: Re: [mihaiolteanu/vuiet] Unable to start Vuiet (#64)
Ok, I've pushed the temp solution to the post-get-request-splithttps://github.com/mihaiolteanu/lastfm.el/blob/b4b19f0aadc5087febeeb3f59944a89c4cdcf325/lastfm.el#L513 branch.
GET works (top-tracks, artist-info, etc) but POST (track-love, scrobble) fails with,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?> <lfm status=\"failed\"> <error code=\"9\">Invalid session key - Please re-authenticate
I've the data and it contains the api_key, secret_key and the api_signature, as before. I haven't changed the code that handles that part.
Any hints? Did I miss something?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/mihaiolteanu/vuiet/issues/64#issuecomment-945554427, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIDY2CGTV2FV3LOTHKSOTFTUHPOVJANCNFSM5FSGFKIA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
@eklebanow nothing, for the moment. Code under development :)
I've pushed the code from above to master (on lastfm.el).
This error has nothing to do with the current implementation,
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<lfm status=\"failed\">
<error code=\"9\">Invalid session key - Please re-authenticate</error>
</lfm>
If you get it, solve it with regenerating the session key (SK), (lastfm-generate-session-key)
(see the README). Maybe add this info to the README.
Also, at some point in the README the sk is wrongly referred to as "Secret Key" (to be updated).
Check your ~/.config/.lastfmrc file. SK might be added twice (a bug). Keep only the newer one.
@eklebanow check it with the new lastfm.el package (either wait for MELPA to pick it up, or git clone it to ~/.emacs/elpa
) and let me know if that works for you.
Many thanks to everyone for your time and support! Mihai
Vuiet working....great job!!
Get Outlook for Androidhttps://aka.ms/AAb9ysg
From: Mihai Olteanu @.> Sent: Tuesday, October 19, 2021 12:13:13 AM To: mihaiolteanu/vuiet @.> Cc: eklebanow @.>; Mention @.> Subject: Re: [mihaiolteanu/vuiet] Unable to start Vuiet (#64)
I've pushed the code from above to master (on lastfm.el).
This error has nothing to do with the current implementation,
<?xml version=\"1.0\" encoding=\"UTF-8\"?> <lfm status=\"failed\"> <error code=\"9\">Invalid session key - Please re-authenticate
If you get it, solve it with regenerating the session key (SK), (lastfm-generate-session-key) (see the READMEhttps://github.com/mihaiolteanu/lastfm.el#install). Maybe add this info to the README. Also, at some point in the README the sk is wrongly referred to as "Secret Key" (to be updated).
Check your ~/.config/.lastfmrc file. SK might be added twice (a bug). Keep only the newer one.
@eklebanowhttps://github.com/eklebanow check it with the new lastfm.el package (either wait for MELPA to pick it up, or git clone it to ~/.emacs/elpa) and let me know if that works for you.
Many thanks to everyone for your time and support! Mihai
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/mihaiolteanu/vuiet/issues/64#issuecomment-946429223, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIDY2CCX34AJSNGZIAO4V6TUHULATANCNFSM5FSGFKIA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
great to hear that you got it working.
After using Vuiet for the past year without issues I am unable to start it. I am running doom emacs on a background of emacs 27.2. Gentoo is my os. What have I tried:
When I call 'vuiet play loved tracks' I get error:
` [error] request-default-error-callback: http://ws.audioscrobbler.com/2.0/?api_key=484d911a7d634cbcc5146b7492522eaf&method=artist.getInfo&artist=madonna error [error] request--callback: peculiar error:
411`I had this same issue previously "error signing into vuiet #11" I do not know what you did on your end to fix but it was fixed and working for a year...now it is not working again``