ModifyMp3FileInfo(r'E:/音乐/12345.mp3')
#!修改下载的Mp3文件名称为正确的Mp3文件
def ModifyMp3FileInfo(filename):
mp3Id3V1 = {
"tag":{"valuepos":(0,3),"value":""},
"SongName":{"valuepos":(3,33),"value":""},
"SongPeople":{"valuepos":(33,63),"value":""},
"Zj":{"valuepos":(63,93),"value":""},
"Year":{"valuepos":(93,97),"value":""},
"Bak":{"valuepos":(97,125),"value":""}
}
try:
f = open(filename,'rb')
f.seek(-128,2)
sdata = f.read(3)
if sdata == 'TAG':
f.seek(-128,2)
sdata = f.read(128)
for tag,subitem in mp3Id3V1.items():
subitem["value"] = sdata[subitem["valuepos"][0]:subitem["valuepos"][1]].replace('/00','').strip()
print '%s='%tag,'%s'%subitem["value"],'/n'
f.close()
import os
if mp3Id3V1["SongName"]["value"]!='':
test = [os.path.dirname(filename),'//']
test.append(mp3Id3V1["SongName"]["value"])
test.append('.mp3')
newfilename = ''.join(test)
print newfilename
if os.path.exists(newfilename):
test = ['Filename ',newfilename,' Has Existed']
print ''.join(test)
else:
try:
os.rename(filename,newfilename)
except WindowsError,e:
if e.winerror:
print 'Modify filename failed ,maybe the file is inuse'
else:
print 'UnKnown error'
else:
print 'Is not a MP3 file'
except IOError:
print 'Open file failed'
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有