Skip to content

Commit 6b7df1a

Browse files
committed
add toc_string to API
This is part of the libdiscid 0.6.0 API
1 parent ef54852 commit 6b7df1a

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

discid/disc.py

+31
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,25 @@ def _get_submission_url(self):
212212
else:
213213
return None
214214

215+
try:
216+
_LIB.discid_get_toc_string.argtypes = (c_void_p, )
217+
_LIB.discid_get_toc_string.restype = c_char_p
218+
except AttributeError:
219+
pass
220+
def _get_toc_string(self):
221+
"""The TOC suitable as value of the `toc parameter`
222+
when accessing the MusicBrainz Web Service.
223+
"""
224+
if self._success:
225+
try:
226+
result = _LIB.discid_get_toc_string(self._handle)
227+
except AttributeError:
228+
return None
229+
else:
230+
return _decode(result)
231+
else:
232+
return None
233+
215234
_LIB.discid_get_first_track_num.argtypes = (c_void_p, )
216235
_LIB.discid_get_first_track_num.restype = c_int
217236
def _get_first_track_num(self):
@@ -292,6 +311,18 @@ def submission_url(self):
292311
url = url.replace("/bare/cdlookup.html", "/cdtoc/attach")
293312
return url
294313

314+
@property
315+
def toc_string(self):
316+
"""The TOC suitable as value of the `toc parameter`
317+
when accessing the MusicBrainz Web Service.
318+
319+
This is a :obj:`unicode` or :obj:`str <python:str>` object
320+
and enables fuzzy searching when the actual Disc ID is not found.
321+
322+
.. seealso:: `MusicBrainz Web Service <http://musicbrainz.org/doc/Development/XML_Web_Service/Version_2#discid>`_
323+
"""
324+
return self._get_toc_string()
325+
295326
@property
296327
def first_track_num(self):
297328
"""Number of the first track"""

doc/api.rst

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Disc object
3333
.. autoattribute:: id
3434
.. autoattribute:: freedb_id
3535
.. autoattribute:: submission_url
36+
.. autoattribute:: toc_string
3637
.. autoattribute:: first_track_num
3738
.. autoattribute:: last_track_num
3839
.. autoattribute:: sectors

0 commit comments

Comments
 (0)