本文整理汇总了Python中mutagen.File.update方法的典型用法代码示例。如果您正苦于以下问题:Python File.update方法的具体用法?Python File.update怎么用?Python File.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mutagen.File
的用法示例。
在下文中一共展示了File.update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tag
# 需要导入模块: from mutagen import File [as 别名]
# 或者: from mutagen.File import update [as 别名]
def tag(filename, data):
audio = File(filename)
audio.delete()
if isinstance(audio, mp3.MP3):
audio.tags = easyid3.EasyID3()
audio.update(data)
audio.save()
示例2: tag
# 需要导入模块: from mutagen import File [as 别名]
# 或者: from mutagen.File import update [as 别名]
def tag(self):
data = self.get_parent_instance().metadata()
with tempfile.NamedTemporaryFile(suffix='-musicdb.mp3') as f:
# Download
with default_storage.open(self.file.location) as g:
contents = g.read()
f.write(contents)
f.flush()
f.seek(0)
audio = MutagenFile(f.name)
audio.delete()
if isinstance(audio, mp3.MP3):
audio.tags = easyid3.EasyID3()
audio.update(data)
audio.save()
self.length = int(audio.info.length)
# Copy it back
default_storage.delete(self.file.location)
dst = default_storage.save(self.file.location, DjangoFile(f))
assert dst == self.file.location
示例3: tag
# 需要导入模块: from mutagen import File [as 别名]
# 或者: from mutagen.File import update [as 别名]
def tag(self):
try:
data = self.get_parent_instance().metadata()
filename = os.path.join(settings.MEDIA_LOCATION, self.file.location)
audio = MutagenFile(filename)
audio.delete()
if isinstance(audio, mp3.MP3):
audio.tags = easyid3.EasyID3()
audio.update(data)
audio.save()
except:
self.tags_dirty = None
self.save()
raise
finally:
self.tags_dirty = False
self.save()
示例4: transfer_tags
# 需要导入模块: from mutagen import File [as 别名]
# 或者: from mutagen.File import update [as 别名]
def transfer_tags(flacfile, wavpackfile):
"""docstring for transfer_tags"""
fl = File(flacfile)
wv = File(wavpackfile)
wv.update(fl)
try:
wv["track"] = wv["tracknumber"]
del wv["tracknumber"]
if wv["totaltracks"]:
wv["track"] = wv["track"][0] + "/" + wv["totaltracks"][0]
del wv["totaltracks"]
wv["disc"] = wv["discnumber"]
del wv["discnumber"]
if wv["totaldiscs"]:
wv["disc"] = wv["disc"][0] + "/" + wv["totaldiscs"][0]
del wv["totaldiscs"]
except KeyError:
pass
wv.save()