本文整理汇总了Python中mutagen.File.delete方法的典型用法代码示例。如果您正苦于以下问题:Python File.delete方法的具体用法?Python File.delete怎么用?Python File.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mutagen.File
的用法示例。
在下文中一共展示了File.delete方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tag
# 需要导入模块: from mutagen import File [as 别名]
# 或者: from mutagen.File import delete [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: write_info2file
# 需要导入模块: from mutagen import File [as 别名]
# 或者: from mutagen.File import delete [as 别名]
def write_info2file(self, info):
# open file with mutagen
audio = File(info['filename'], easy=True)
if audio is None:
return
if self.container.config.always_remove_tags:
if audio.tags is not None:
audio.delete()
else:
# write title+album information into audio files
if audio.tags is None:
audio.add_tags()
# write album+title
if info['album'] is not None:
audio.tags['album'] = info['album']
if info['title'] is not None:
audio.tags['title'] = info['title']
# write genre tag
if self.container.config.genre_tag is not None:
audio.tags['genre'] = self.container.config.genre_tag
else:
audio.tags['genre'] = ''
# write pubDate
if info['pubDate'] is not None:
audio.tags['date'] = info['pubDate']
audio.save()
示例3: tag
# 需要导入模块: from mutagen import File [as 别名]
# 或者: from mutagen.File import delete [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
示例4: save
# 需要导入模块: from mutagen import File [as 别名]
# 或者: from mutagen.File import delete [as 别名]
def save(pf):
metadata = Metadata()
metadata.copy(pf.metadata)
mf = MFile(pf.filename)
if mf is not None:
mf.delete()
return pf._save_and_rename(pf.filename, metadata)
示例5: tag
# 需要导入模块: from mutagen import File [as 别名]
# 或者: from mutagen.File import delete [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()
示例6: remove_tags
# 需要导入模块: from mutagen import File [as 别名]
# 或者: from mutagen.File import delete [as 别名]
def remove_tags(self):
audio = File(self.filename, easy=True)
if audio.tags is not None:
audio.delete()
audio.save()
示例7: test_clear_metadata
# 需要导入模块: from mutagen import File [as 别名]
# 或者: from mutagen.File import delete [as 别名]
def test_clear_metadata(filename):
t = MFile(filename)
t.delete()
t.save()