当前位置: 首页>>代码示例>>Python>>正文


Python File.delete方法代码示例

本文整理汇总了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()
开发者ID:MechanisM,项目名称:musicdb,代码行数:9,代码来源:tagging.py

示例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()
开发者ID:njsf,项目名称:gpodder,代码行数:33,代码来源:tagging.py

示例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
开发者ID:lamby,项目名称:musicdb,代码行数:30,代码来源:models.py

示例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)
开发者ID:AzoresOne,项目名称:picard-plugins,代码行数:9,代码来源:save_and_rewrite_header.py

示例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()
开发者ID:MechanisM,项目名称:musicdb,代码行数:19,代码来源:models.py

示例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()
开发者ID:skysign,项目名称:gpodder,代码行数:7,代码来源:tagging.py

示例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()
开发者ID:NCenerar,项目名称:main,代码行数:6,代码来源:main.py


注:本文中的mutagen.File.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。