利用python修改mp3的标签

来源:互联网 发布:设计ui的软件 编辑:程序博客网 时间:2024/05/19 15:20

新买了mac pro的电脑,使用itune在听原来的歌曲的时候,发现itunes对原来歌曲的管理乱七八糟的,仔细一看其原来是按照专辑等信息进行分类的。由于网络上下载的mp3的标签大多数都不规范,因此一直想着个机会做一个mp3标签修改的程序。今天利用空余时间使用python写了一个修改程序

第一步:安装mp3的标签编辑程序,具体资源参照本人上传的资源
点击打开链接

第二步:修改某个问价夹下面所有后缀是mp3的文件标签,具体程序如下
import eyed3import osdef modifyID3(filename,title):        audiofile=eyed3.load(filename)        audiofile.tag.artist = u"Travelers"        audiofile.tag.album = u"Travelers"        audiofile.tag.title = title        #audiofile.tag.track_num = 4        audiofile.tag.save()prefix=r".mp3"for eachfile in os.listdir(r"/home/ukylin/Travelers"):        length=len(eachfile)        print eachfile[length-4:length]        if cmp(prefix,eachfile[length-4:length])==0:                print u""+eachfile[0:length-4]                modifyID3(eachfile,u""+eachfile[0:length-4])


这个具体可以修改如下的标签:
return {"artist": tag.artist if tag else None,                "album": tag.album if tag else None,                "title": tag.title if tag else None,                "track:num": (self._track, zeropad) if tag else None,                "track:total": (self._track, zeropad) if tag else None,                "release_date": (self._release_date,) if tag else None,                "release_date:year": (self._release_date,) if tag else None,                "file": (self._file,) if tag else None,                "file:ext": (self._file,) if tag else None,               }


原创粉丝点击