本文整理汇总了Python中mutagen.flac.FLAC.tags['genre']方法的典型用法代码示例。如果您正苦于以下问题:Python FLAC.tags['genre']方法的具体用法?Python FLAC.tags['genre']怎么用?Python FLAC.tags['genre']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mutagen.flac.FLAC
的用法示例。
在下文中一共展示了FLAC.tags['genre']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tagFile
# 需要导入模块: from mutagen.flac import FLAC [as 别名]
# 或者: from mutagen.flac.FLAC import tags['genre'] [as 别名]
def tagFile(self,filename,metadata,art_url):
image = None
if art_url is not None:
self.getFile('artwork.jpg',art_url,True)
try:
with open('artwork.jpg','rb') as file:
image = file.read()
except:
pass
if(filename.endswith('.mp3')):
audio = MP3(filename,ID3=ID3)
try:
audio.add_tags()
except:
pass
audio.tags.add(
APIC(
encoding=3,
mime='image/jpeg',
type=3,
desc=u'Cover',
data=image
)
)
audio.tags["TIT2"] = TIT2(encoding=3, text=metadata['title'])
audio.tags["TPE1"] = TPE1(encoding=3, text=metadata['artist'])
audio.tags["TDRC"] = TDRC(encoding=3, text=unicode(metadata['year']))
audio.tags["TCON"] = TCON(encoding=3, text=metadata['genre'])
audio.save()
elif(filename.endswith('.flac')):
audio = FLAC(filename)
try:
audio.add_tags()
except:
pass
audio.tags['title'] = metadata['title']
audio.tags['artist'] = metadata['artist']
audio.tags['year'] = metadata['year']
audio.tags['genre'] = metadata['genre']
audio.tags.add(
APIC(
encoding=3,
mime='image/jpeg',
type=3,
desc=u'Cover',
data=image
)
)
audio.save()
elif(filename.endswith('.m4a')):
audio = MP4(filename)
try:
audio.add_tags()
except:
pass
covr = []
covr.append(MP4Cover(image, MP4Cover.FORMAT_JPEG))
audio.tags['covr'] = covr
audio.tags['title'] = metadata['title']
audio.tags['artist'] = metadata['artist']
#audio.tags['year'] = metadata['year']
audio.tags['genre'] = metadata['genre']
audio.save()
if os.path.isfile('artwork.jpg'):
os.remove('artwork.jpg')