读取.flac文件时,Mutagen会抛出错误

时间:2016-02-28 12:58:02

标签: python-3.x mutagen

我已将此脚本编码为从FLAC文件中读取元数据,有时它可以正常工作,但有时会抛出此错误并且不知道原因。这些文件没有损坏。似乎无法阅读某些FLAC文件的标题,但我不知道如何解决这个问题。

这是代码:

def get_meta():
    for dirpath, directories, files in os.walk(XPATH):
        for sound_file in files:
            date = artist = album = title = genre = ""
            if sound_file.endswith('.flac'):
                print('Flac file found, getting metadata and renaming...')
                flac_file = os.path.join(dirpath, sound_file)
                from mutagen.flac import FLAC
                metadata = mutagen.flac.Open(flac_file)



File "recursivetest.py", line 54, in get_sound
    metadata = mutagen.flac.Open(flac_file)
  File "/home/xavier/Code/autotube/venv/lib/python3.5/site-packages/mutagen/_file.py", line 42, in __init__
    self.load(filename, *args, **kwargs)
  File "/home/xavier/Code/auto/venv/lib/python3.5/site-packages/mutagen/flac.py", line 759, in load
    self.__check_header(fileobj)
  File "/home/xavier/Code/auto/venv/lib/python3.5/site-packages/mutagen/flac.py", line 857, in __check_header
    header = fileobj.read(4)
  File "/home/xavier/Code/auto/venv/lib/python3.5/site-packages/mutagen/flac.py", line 68, in read
    size, len(data)))
mutagen.flac.error: file said 4 bytes, read 0 bytes

0 个答案:

没有答案