Closed noyse27 closed 3 years ago
that's odd, i tested it before merging and scrobbled a few tracks.
will check
No error here, did you put your user token in?
2019-09-19 17:49:06 [user] (listenbrainz.plugin) -> Submission content: {"listen_type":"single","payload":[{"listened_at":1568879346,"track_metadata":{"additional_info":{"recording_mbid":"694da04d-1ffc-435c-8b4b-59cc23ac8003","release_mbid":"84ad6fdf-491a-4c33-9fba-b684c9063e37","artist_mbid":"f4abc0b5-3f7a-4eff-8f78-ac078dbce533"},"artist_name":"Billie Eilish","track_name":"bad guy","release_name":"WHEN WE ALL FALL ASLEEP, WHERE DO WE GO?"}}]}
2019-09-19 17:49:06 [user] (listenbrainz.plugin) -> Submission option: {"http":{"method":"POST","header":["Authorization: token 9a369bcd-275a-46e3-a23c-af2ae48ef434","Content-type: application\/json; charset=utf-8","Content-length: 376"],"content":"{\"listen_type\":\"single\",\"payload\":[{\"listened_at\":1568879346,\"track_metadata\":{\"additional_info\":{\"recording_mbid\":\"694da04d-1ffc-435c-8b4b-59cc23ac8003\",\"release_mbid\":\"84ad6fdf-491a-4c33-9fba-b684c9063e37\",\"artist_mbid\":\"f4abc0b5-3f7a-4eff-8f78-ac078dbce533\"},\"artist_name\":\"Billie Eilish\",\"track_name\":\"bad guy\",\"release_name\":\"WHEN WE ALL FALL ASLEEP, WHERE DO WE GO?\"}}]}"}}
2019-09-19 17:49:07 [user] (listenbrainz.plugin) -> Submission Successful: {"status":"ok"}
2019-09-19 17:49:07 [user] (listenbrainz.plugin) ->
2019-09-19 17:49:07 [user] (useractivity.class) -> Inserting details for bad guy - Billie Eilish - WHEN WE ALL FALL ASLEEP, WHERE DO WE GO?.
it works correctly without a token as with a fake token it fails out for me as well.
2019-09-19 17:52:45 [user] (listenbrainz.plugin) -> Submission content: {"listen_type":"single","payload":[{"listened_at":1568879565,"track_metadata":{"additional_info":{"recording_mbid":"912dd3db-d47b-43c8-a10f-dd1e94736302","release_mbid":"3de1553c-e4fe-4275-a0dd-6a8e93d015f3","artist_mbid":"e29b7e7f-172a-4eff-a1b5-04e6e20d040e"},"artist_name":"Celluloide","track_name":"This Aching Kiss (Foretaste remix)","release_name":"Num\u00e9riques (3)"}}]}
2019-09-19 17:52:45 [user] (listenbrainz.plugin) -> Submission option: {"http":{"method":"POST","header":["Authorization: token FAKETOKEN","Content-type: application\/json; charset=utf-8","Content-length: 379"],"content":"{\"listen_type\":\"single\",\"payload\":[{\"listened_at\":1568879565,\"track_metadata\":{\"additional_info\":{\"recording_mbid\":\"912dd3db-d47b-43c8-a10f-dd1e94736302\",\"release_mbid\":\"3de1553c-e4fe-4275-a0dd-6a8e93d015f3\",\"artist_mbid\":\"e29b7e7f-172a-4eff-a1b5-04e6e20d040e\"},\"artist_name\":\"Celluloide\",\"track_name\":\"This Aching Kiss (Foretaste remix)\",\"release_name\":\"Num\\u00e9riques (3)\"}}]}"}}
019-09-19 17:52:46 [ampache] (log.lib) -> [Runtime Error] file_get_contents(https://api.listenbrainz.org/1/submit-listens): failed to open stream: HTTP request failed! HTTP/1.1 401 UNAUTHORIZED
2019-09-19 17:52:46 [ampache] (log.lib) -> in file /var/www/music/modules/plugins/ListenBrainz/ListenBrainz.plugin.php(177)
2019-09-19 17:52:46 [user] (listenbrainz.plugin) -> Submission Successful:
2019-09-19 17:52:46 [user] (useractivity.class) -> Inserting details for This Aching Kiss (Foretaste remix) - Celluloide - Numériques (3).
2019-09-19 17:52:46 [user] (play/index) -> Stream ended at 9587847 (9587847) bytes out of 9587847
019-09-19 17:52:47 [ampache] (log.lib) -> [Runtime Error] file_get_contents(https://api.listenbrainz.org/1/submit-listens): failed to open stream: HTTP request failed! HTTP/1.1 401 UNAUTHORIZED
2019-09-19 17:52:47 [ampache] (log.lib) -> in file /var/www/music/modules/plugins/ListenBrainz/ListenBrainz.plugin.php(177)
2019-09-19 17:52:47 [user] (listenbrainz.plugin) -> Submission Successful:
@lachlan-00
after activating open_ssl in php.ini it seems arriving listenbrainz now
but i still get an error - now a 500
(listenbrainz.plugin) -> Submission content: {"listen_type":"single","payload":[{"listened_at":1568882917,"track_metadata":{"additional_info":[],"artist_name":"Erasure","track_name":"Hideaway","release_name":"Live at Short Circuit"}}]}
2019-09-19 10:48:37 [user] (listenbrainz.plugin) -> Submission option: {"http":{"method":"POST","header":["Authorization: token xxx","Content-type: application\/json; charset=utf-8","Content-length: 190"],"content":"{\"listen_type\":\"single\",\"payload\":[{\"listened_at\":1568882917,\"track_metadata\":{\"additional_info\":[],\"artist_name\":\"Erasure\",\"track_name\":\"Hideaway\",\"release_name\":\"Live at Short Circuit\"}}]}"}}
019-09-19 10:48:37 [ampache] (log.lib) -> [Runtime Error] file_get_contents(https://api.listenbrainz.org/1/submit-listens): failed to open stream: HTTP request failed! HTTP/1.1 500 INTERNAL SERVER ERROR
2019-09-19 10:48:37 [ampache] (log.lib) -> in file /volume1/web/ampache-git/ampache/modules/plugins/ListenBrainz/ListenBrainz.plugin.php(176)
2019-09-19 10:48:37 [noyse] (listenbrainz.plugin) -> Submission Successful:
@ibmibmibm have you encountered this?
i can't reproduce this error at all. the plugin is basically the last.fm rebranded so i'm not sure why you're not able to connect.
@lachlan-00 maybe it's because it's running on Synology Disc Station. I also had problems with the last.fm plugin at the beginning. In the end I have reached the point where it reaches listenbrainz but gets a http 500 error back from there. In some forums I read that this can be fixed if you switch from file_gets_content to curl. I don't know how to do that now. Maybe I'll try it later.
You might be able to use somehting like follow_stream
/**
* @param string $url
*/
public static function follow_stream($url)
{
set_time_limit(0);
ob_end_clean();
header("Access-Control-Allow-Origin: *");
if (function_exists('curl_version')) {
// Here, we use curl from the Ampache server to download data from
// the Ampache server, which can be a bit counter-intuitive.
// We use the curl `writefunction` and `headerfunction` callbacks
// to write the fetched data back to the open stream from the
// client.
$headers = apache_request_headers();
$reqheaders = array();
$reqheaders[] = "User-Agent: " . $headers['User-Agent'];
if (isset($headers['Range'])) {
$reqheaders[] = "Range: " . $headers['Range'];
}
// Curl support, we stream transparently to avoid redirect. Redirect can fail on few clients
debug_event('subsonic_api.class', 'Stream proxy: ' . $url, 5);
$curl = curl_init($url);
curl_setopt_array($curl, array(
CURLOPT_FAILONERROR => true,
CURLOPT_HTTPHEADER => $reqheaders,
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => false,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_WRITEFUNCTION => array('Subsonic_Api', 'output_body'),
CURLOPT_HEADERFUNCTION => array('Subsonic_Api', 'output_header'),
// Ignore invalid certificate
// Default trusted chain is crap anyway and currently no custom CA option
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_TIMEOUT => 0
));
if (curl_exec($curl) === false) {
debug_event('subsonic_api.class', 'Stream error: ' . curl_error($curl), 1);
}
curl_close($curl);
} else {
// Stream media using http redirect if no curl support
// Bug fix for android clients looking for /rest/ in destination url
// Warning: external catalogs will not work!
$url = str_replace('/play/', '/rest/fake/', $url);
header("Location: " . $url);
}
}
i will try
I guess that PHP cannot recognizing https protocol and using http to communicated with api server.
@ibmibmibm is this something i can handle ? if yes how?
I have a similar issue, but for me only some Albums/Tracks are not submitted:
2019-11-26 20:44:55 [henrik] (listenbrainz.plugin) -> Submission content: {"listen_type":"single","payload":[{"listened_at":1574797495,"track_metadata":{"addi
tional_info":[],"artist_name":"Tenacious D","track_name":"Deth Starr","release_name":"Rize Of The Fenix (Deluxe Edition)"}}]}
2019-11-26 20:44:55 [henrik] (listenbrainz.plugin) -> Submission option: {"http":{"method":"POST","header":["Authorization: token xxx","Content-type: application\/json; charset=utf-8","Content-length: 209"],"content":"{\"listen_type\":\"single\",\"payload\":[{\"listened_at\":1574797
495,\"track_metadata\":{\"additional_info\":[],\"artist_name\":\"Tenacious D\",\"track_name\":\"Deth Starr\",\"release_name\":\"Rize Of The Fenix (Deluxe Edit
ion)\"}}]}"}}
2019-11-26 20:44:56 [ampache] (log.lib) -> [Runtime Error] file_get_contents(https://api.listenbrainz.org/1/submit-listens): failed to open stream: HTTP req e
st failed! HTTP/1.1 500 INTERNAL SERVER ERROR
2019-11-26 20:44:56 [henrik] (listenbrainz.plugin) -> Submission Failed
2019-11-26 20:49:43 [henrik] (listenbrainz.plugin) -> Submission content: {"listen_type":"single","payload":[{"listened_at":1574797783,"track_metadata":{"addi
tional_info":[],"artist_name":"Tenacious D","track_name":"Roadie","release_name":"Rize Of The Fenix (Deluxe Edition)"}}]}
2019-11-26 20:49:43 [henrik] (listenbrainz.plugin) -> Submission option: {"http":{"method":"POST","header":["Authorization: token xxxx","Content-type: application\/json; charset=utf-8","Content-length: 205"],"content":"{\"listen_type\":\"single\",\"payload\":[{\"listened_at\":1574797
783,\"track_metadata\":{\"additional_info\":[],\"artist_name\":\"Tenacious D\",\"track_name\":\"Roadie\",\"release_name\":\"Rize Of The Fenix (Deluxe Edition)
\"}}]}"}}
2019-11-26 20:49:43 [ampache] (log.lib) -> [Runtime Error] file_get_contents(https://api.listenbrainz.org/1/submit-listens): failed to open stream: HTTP req e
st failed! HTTP/1.1 500 INTERNAL SERVER ERROR
2019-11-26 20:49:43 [henrik] (listenbrainz.plugin) -> Submission Failed
2019-11-26 20:52:16 [henrik] (listenbrainz.plugin) -> Submission content: {"listen_type":"single","payload":[{"listened_at":1574797936,"track_metadata":{"addi
tional_info":{"artist_mbid":"b95ce3ff-3d05-4e87-9e01-c97b66af13d4"},"artist_name":"Eminem","track_name":"Baby","release_name":"Marshall Mathers LP 2"}}]}
2019-11-26 20:52:16 [henrik] (listenbrainz.plugin) -> Submission option: {"http":{"method":"POST","header":["Authorization: token xxxx","Content-type: application\/json; charset=utf-8","Content-length: 237"],"content":"{\"listen_type\":\"single\",\"payload\":[{\"listened_at\":1574797
936,\"track_metadata\":{\"additional_info\":{\"artist_mbid\":\"b95ce3ff-3d05-4e87-9e01-c97b66af13d4\"},\"artist_name\":\"Eminem\",\"track_name\":\"Baby\",\"re
lease_name\":\"Marshall Mathers LP 2\"}}]}"}}
2019-11-26 20:52:16 [henrik] (listenbrainz.plugin) -> Submission Successful
2019-11-26 20:56:40 [henrik] (listenbrainz.plugin) -> Submission content: {"listen_type":"single","payload":[{"listened_at":1574798200,"track_metadata":{"addi
tional_info":{"artist_mbid":"b95ce3ff-3d05-4e87-9e01-c97b66af13d4"},"artist_name":"Eminem","track_name":"Baby","release_name":"Marshall Mathers LP 2"}}]}
2019-11-26 20:56:40 [henrik] (listenbrainz.plugin) -> Submission option: {"http":{"method":"POST","header":["Authorization: token xxxxx","Content-type: application\/json; charset=utf-8","Content-length: 237"],"content":"{\"listen_type\":\"single\",\"payload\":[{\"listened_at\":1574798
200,\"track_metadata\":{\"additional_info\":{\"artist_mbid\":\"b95ce3ff-3d05-4e87-9e01-c97b66af13d4\"},\"artist_name\":\"Eminem\",\"track_name\":\"Baby\",\"re
lease_name\":\"Marshall Mathers LP 2\"}}]}"}}
2019-11-26 20:56:41 [henrik] (listenbrainz.plugin) -> Submission Successful
2019-11-26 20:57:46 [henrik] (listenbrainz.plugin) -> Submission content: {"listen_type":"single","payload":[{"listened_at":1574798266,"track_metadata":{"addi
tional_info":{"artist_mbid":"b95ce3ff-3d05-4e87-9e01-c97b66af13d4"},"artist_name":"Eminem","track_name":"Brainless","release_name":"Marshall Mathers LP 2"}}]}
I compared the requests to listenbrainz:
This one worked:
{
"listen_type": "single",
"payload": [
{
"listened_at": 1574798554,
"track_metadata": {
"additional_info": {
"artist_mbid": "b95ce3ff-3d05-4e87-9e01-c97b66af13d4"
},
"artist_name": "Eminem",
"track_name": "Cleanin' Out My Closet",
"release_name": "Curtain Call: The Hits"
}
}
]
}
This is the bad one:
{
"listen_type": "single",
"payload": [
{
"listened_at": 1574799100,
"track_metadata": {
"additional_info": [],
"artist_name": "Tenacious D",
"track_name": "Kickapoo",
"release_name": "Pick Of Destiny"
}
}
]
}
When I edit the request and replace [] with {} it works:
{
"listen_type": "single",
"payload": [
{
"listened_at": 1574799100,
"track_metadata": {
"additional_info": {},
"artist_name": "Tenacious D",
"track_name": "Kickapoo",
"release_name": "Pick Of Destiny"
}
}
]
}
I am not a PHP guy, but maybe the default value should be set to "{}" if no mbid is available? https://github.com/ampache/ampache/blob/212496fc407ac7cbcce39cef6ff81348a0d77a34/modules/plugins/ListenBrainz/ListenBrainz.plugin.php#L123-L146
That's good to know. I'll look at the way the json request is built
If it's null it's probably as simple as checking whether the additional info is empty
I'll find some files with one of each, all and no mbid to test
@acidwars thx thats exactly the problem. due to i only have les files with musicbrainz id i do not send additional infos anymore, and now it works :)
Thanks for reminding me about this i need to sit with it again today.
Okay, i see the api docs say it's optional so i'll remove it if empty. that should fix it.
The following optional elements may also be included in the additional_info element. If you do not have the data for any of the following fields, omit the key entirely:
Appears to be fixed? Closing
Issue Template
Environment
Settings
Description
Listenbrainz does not submit something - throws error in log
Logs