python-musicbrainz: Difference between revisions
RobertKaye (talk | contribs) ((Imported from MoinMoin)) |
(No difference)
|
Revision as of 22:44, 5 January 2007
Python MusicBrainz
Introduction
python-musicbrainz is a python wrapper for the libmusicbrainz. It is a straight python to c binding, and uses ctypes to avoid having to write c code. You'll have to get and download the ctypes module from the author, or if you have debian unstable, you can apt-get it. This project is now a part of the MusicBrainz Client library libmusicbrainz.
- PythonMusicbrainz is deprecated, and replaced by the new client bindings PythonMusicBrainz2. Please use the new python bindings in new projects, since the old RDF Web Service will be moved out of service soon. For more details see WebService.
Comments
Are there any docs available for PM? Offers the mb_client similar functions?? - FloK
Any ideas to this error?
flo@groovesurfer examples $ ./cdid.py Insert CD and hit enter... querying musicbrainz.org to see if this cd is on there... Traceback (most recent call last): File "./cdid.py", line 54, in ? main() File "./cdid.py", line 42, in main url = mb.GetWebSubmitURL() File "/home/httpd/musicbrainz/python-musicbrainz/examples/musicbrainz.py", line 149, in GetWebSubmitURL if not mbdll.mb_GetWebSubmitURL(self.mb, url, BUFSIZE): TypeError: while constructing argument 2: string expected instead of c_char_Array_1024 instance
In regard to the above error, I have some good news and some bad news. First, the good news. That particular error is caused by your ctypes being horribly old. The one in debian unstable is 0.6.3, in contrast to the 0.9.0 that's shipping from SourceForge. Upgrade and the error magically disappears. --MatthewDaniel
Now the bad news: after upgrading ctypes, I get a different error using python-musicbrainz 1.0b1:
Traceback (most recent call last): File "./examples/cdlookup.py", line 12, in ? main() File "./examples/cdlookup.py", line 7, in main mb = musicbrainz.mb() File "/usr/lib/python2.3/site-packages/musicbrainz.py", line 42, in __init__ mbdll.mb_UseUTF8(self.mb, True) TypeError: while constructing argument 1: wrong type Exception exceptions.AttributeError: "mb instance has no attribute 'mbdll'" in <bound method mb.__del__ of <musicbrainz.mb instance at 0x401eb6cc>> ignored
Never one content to let sleeping dogs lie, I played around with ctypes and figured out that (at least with ctypes 0.9.0 on Python 2.3.4) it does not do very much (if any) implicit casting. I wrapped the self.mb
above with a call to the c_void_p
constructor: c_void_p(self.mb)
and it fired right up (after I wrapped all the other calls, too, naturally). I will submit a patch in SourceForge in a bit, but wanted to update this so the trail wasn't a dead-end for other folks. --MatthewDaniel
What is PythonMusicbrainz? Could someone please add a short note here and on the homepage? Thanks --DonRedman
- PythonMusicbrainz exposes the libmusicbrainz API calls via a Python object interface. This allows clients to leverage the Musicbrainz mb_client functions without mucking around with malloc, integer return codes and other miscellaneous C fun. --MatthewDaniel