quodlibet / mutagen

Python module for handling audio metadata
https://mutagen.readthedocs.io
GNU General Public License v2.0
1.56k stars 158 forks source link

flac: Add example for adding a cue sheet block #224

Open lazka opened 9 years ago

lazka commented 9 years ago

Originally reported by: Gates Wong (Bitbucket: gatesice, GitHub: Unknown)


from mutagen import flac

cue_file_utf8 = "手嶌葵 - 春の歌集.utf8.cue"

with open(cue_file_utf8) as fp:
    cue_obj = flac.CueSheet(fp)

It raises the error:

/Library/Python/2.7/site-packages/mutagen/flac.pyc in read(self, size)
     65         if size >= 0 and len(data) != size:
     66             raise error("file said %d bytes, read %d bytes" % (
---> 67                         size, len(data)))
     68         return data
     69 

error: file said 396 bytes, read 0 bytes

If I use:

with open(cue_file_utf8) as fp:
    cue_obj = flac.CueSheet(fp.read())

I got:

/Library/Python/2.7/site-packages/mutagen/flac.pyc in read(self, size)
     65         if size >= 0 and len(data) != size:
     66             raise error("file said %d bytes, read %d bytes" % (
---> 67                         size, len(data)))
     68         return data
     69 

error: file said 36 bytes, read 33 bytes

lazka commented 9 years ago

Original comment by Christoph Reiter (Bitbucket: lazka, GitHub: lazka):


mutagen can't read cue sheet files. It can only read/write flac cue sheet block [0]

[0] https://xiph.org/flac/format.html#metadata_block_cuesheet