Hi,
I’m trying to get musicbrainzngs.get_recording_by_id() to return something sensible but not having a lot of luck at the moment, so I thought I’d ask some basic questions in order to isolate the problem.
Check out the following Python Code:
musicbrainzngs.auth('***', '***')
musicbrainzngs.set_useragent('MusicCheck',1,contact='dave@looktowindward.com')
musicbrainzngs.set_format('json')
myResult = musicbrainzngs.search_artists(artist=myArtist, type="group", strict=True)
myArtistList = myResult['artists']
myArtistDict = myArtistList[0]
myArtistID = myArtistDict['id']
myResult = musicbrainzngs.get_artist_by_id(id=myArtistID,includes=['release-groups'], release_type=['album'])
myReleaseGroupDict = myResult['release-groups']
for myReleaseDict in myReleaseGroupDict:
if myReleaseDict['title'] == myAlbum:
myAlbumID = myReleaseDict['id']
print('Matched:', myAlbum, ' AlbumID:',myAlbumID)
break
myResult = musicbrainzngs.get_recording_by_id(id=myAlbumID, includes=['releases'], release_status=['official'], release_type=['album'])
print(myResult)
Apart from the call to musicbrainzngs.get_recording_by_id, this works fine, so some basic questions:
-
What should I be passing to this method as the ID? I have the ArtistID and the AlbumID (ReleaseID?) both returned from MB, which one should I pass? I’ve tried both and they both fail.
-
What should I pass as the other parameters, the parameters I am passing are the same as the call to get_artist_by_id method, so I would have thought they would be valid?
When I run this, I get the following error:
Matched: White Light/White Heat AlbumID: fc0885e0-0284-3f9d-81ee-17c5e7196346
Traceback (most recent call last):
File "/Documents/Development/Projects/Python/Test1/venv/lib/python3.9/site-packages/musicbrainzngs/musicbrainz.py", line 497, in _safe_read
f = opener.open(req)
File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 523, in open
response = meth(req, response)
File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 632, in http_response
response = self.parent.error(
File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 561, in error
return self._call_chain(*args)
File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 494, in _call_chain
result = func(*args)
File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 641, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Documents/Development/Projects/Python/Test1/main.py", line 130, in <module>
myResult = musicbrainzngs.get_recording_by_id(id=myAlbumID, includes=['releases'], release_status=['official'], release_type=['album'])
File "/Documents/Development/Projects/Python/Test1/venv/lib/python3.9/site-packages/musicbrainzngs/musicbrainz.py", line 870, in get_recording_by_id
return _do_mb_query("recording", id, includes, params)
File "/Documents/Development/Projects/Python/Test1/venv/lib/python3.9/site-packages/musicbrainzngs/musicbrainz.py", line 728, in _do_mb_query
return _mb_request(path, 'GET', auth_required, args=args)
File "/Documents/Development/Projects/Python/Test1/venv/lib/python3.9/site-packages/musicbrainzngs/musicbrainz.py", line 417, in __call__
return self.fun(*args, **kwargs)
File "/Documents/Development/Projects/Python/Test1/venv/lib/python3.9/site-packages/musicbrainzngs/musicbrainz.py", line 690, in _mb_request
resp = _safe_read(opener, req, body)
File "/Documents/Development/Projects/Python/Test1/venv/lib/python3.9/site-packages/musicbrainzngs/musicbrainz.py", line 503, in _safe_read
raise ResponseError(cause=exc)
musicbrainzngs.musicbrainz.ResponseError: caused by: HTTP Error 404: Not Found
Process finished with exit code 1
Any help would be greatly appreciated.
All the Best
Dave