Mutagen无法打开文件ID3BadUnsyncError

时间:2012-08-12 22:16:44

标签: python mutagen

我正在编写一个python脚本,使用mutagen库重新格式化我音乐文件夹中文件的名称。这是脚本:

from mutagen.easyid3 import EasyID3
import os

print "input directory for processing: "
path = raw_input()
os.chdir(path)        

file_list = filter((lambda x: '.mp3' in x), os.listdir(path))

for i in file_list:
        current = EasyID3(i)
        newname = current["title"][0] + ".mp3"
        newname.replace(" ", "_")
        del current
        print "renaming "+i+" to "+newname
        os.rename(i, newname)

以下是我尝试运行时会发生的事情:

$ python rename_music.py
input directory for processing: 
/home/james/Music/inscrutable_numbers
Traceback (most recent call last):
  File "rename_music.py", line 11, in <module>
    current = EasyID3(i)
  File "/usr/local/lib/python2.7/dist-packages/mutagen/easyid3.py", line 167, in __init__
    self.load(filename)
  File "/usr/local/lib/python2.7/dist-packages/mutagen/id3.py", line 139, in load
    for frame in self.__read_frames(data, frames=frames):
  File "/usr/local/lib/python2.7/dist-packages/mutagen/id3.py", line 317, in __read_frames
    try: yield self.__load_framedata(tag, flags, framedata)
  File "/usr/local/lib/python2.7/dist-packages/mutagen/id3.py", line 340, in __load_framedata
    return tag.fromData(self, flags, framedata)
  File "/usr/local/lib/python2.7/dist-packages/mutagen/id3.py", line 1085, in fromData
    raise ID3BadUnsynchData, '%s: %r' % (err, data)
mutagen.id3.ID3BadUnsynchData: invalid sync-safe string: '\x00j\x01\x0c\x00\x12(...lots of unicode...)\x12\xff\xff\xff\x00'

有谁知道这里的问题是什么?

编辑:结果mutagen不适用于某些文件。我添加了一个try子句并跳过了错误,现在可以使用了

0 个答案:

没有答案