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


Python OggVorbis.delete方法代码示例

本文整理汇总了Python中mutagen.oggvorbis.OggVorbis.delete方法的典型用法代码示例。如果您正苦于以下问题:Python OggVorbis.delete方法的具体用法?Python OggVorbis.delete怎么用?Python OggVorbis.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mutagen.oggvorbis.OggVorbis的用法示例。


在下文中一共展示了OggVorbis.delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: remove_all

# 需要导入模块: from mutagen.oggvorbis import OggVorbis [as 别名]
# 或者: from mutagen.oggvorbis.OggVorbis import delete [as 别名]
    def remove_all(self):
        if self.backup is True:
            shutil.copy2(self.filename, self.output)
            self.filename = self.output

        mfile = OggVorbis(self.filename)
        mfile.delete()
        mfile.save()
开发者ID:4ZM,项目名称:Metadata-Anonymisation-Toolkit,代码行数:10,代码来源:audio.py

示例2: remove_metadata

# 需要导入模块: from mutagen.oggvorbis import OggVorbis [as 别名]
# 或者: from mutagen.oggvorbis.OggVorbis import delete [as 别名]
 def remove_metadata(self):
     if MUTAGEN:
         if "mpeg" in self.__mime_type and "MP3" in self.__audio_codec:
             try:
                 tags = ID3(self.__filepath)
             except ID3NoHeaderError:
                 return
             tags.delete(self.__filepath, delete_v1=True, delete_v2=True)
         elif "ogg" in self.__mime_type:
             tags = OggVorbis(self.__filepath)
             tags.delete()
         elif "flac" in self.__mime_type:
             tags = FLAC(self.__filepath)
             tags.delete()
开发者ID:giorgiofranceschi,项目名称:xaudiocopy,代码行数:16,代码来源:AudioFile.py

示例3: MP3

# 需要导入模块: from mutagen.oggvorbis import OggVorbis [as 别名]
# 或者: from mutagen.oggvorbis.OggVorbis import delete [as 别名]
# Write the tag data
for t in tag_data:
    if t['track_format'] == 'mp3':
        mp3 = MP3(t['track_fname'])
        mp3.delete()

        mp3['TPE1'] = TPE1(encoding=3, text=t['track_artist'])
        mp3['TALB'] = TALB(encoding=3, text=t['album'])
        mp3['TDRC'] = TDRC(encoding=3, text=t['year'])
        mp3['TRCK'] = TRCK(encoding=3, text=t['track_num'])
        mp3['TIT2'] = TIT2(encoding=3, text=t['track_title'])
        mp3.save()

    elif t['track_format'] == 'ogg':
        ogg = OggVorbis(t['track_fname'])
        ogg.delete()

        ogg['artist'] = t['track_artist']
        ogg['album'] = t['album']
        ogg['date'] = t['date']
        ogg['year'] = t['year']
        ogg['tracknumber'] = t['track_num']
        ogg['title'] = t['track_title']
        ogg.save()

    elif t['track_format'] == 'flac':
        flac = FLAC(t['track_fname'])
        flac.delete()

        flac['artist'] = t['track_artist']
        flac['album'] = t['album']
开发者ID:bkong,项目名称:music-tagger,代码行数:33,代码来源:tag-album.py

示例4: __init__

# 需要导入模块: from mutagen.oggvorbis import OggVorbis [as 别名]
# 或者: from mutagen.oggvorbis.OggVorbis import delete [as 别名]

#.........这里部分代码省略.........
        self.ogg = None
        self.quiet = kwargs.get('quiet', False)

        try: self.id3 = ID3(filename)
        except IOError:
            self._warn("error reading file")
        except ID3NoHeaderError: pass
        except ID3BadUnsynchData:
            self._warn("error parsing ID3 tag")

        try: self.ape = APEv2(filename)
        except IOError: pass
        except APENoHeaderError: pass

        try: self.ogg = OggVorbis(filename)
        except IOError: pass

    def _warn(self, message):
        if not self.quiet:
            print u"{0}: {1}".format(self.filename, message)

    def dirty_containers(self):
        """Return a list of the containers clean() will remove"""
        c = []
        if (self.id3 or self.ogg) and self.ape:
            if self.ape: c.append(self.ape.__class__.__name__)
        if self.id3 and self.ogg:
            if self.ogg: c.append(self.ogg.__class__.__name__)
        return c

    def dirty_tags(self):
        """Return a list of tags clean() will remove"""
        if self.id3:
            return [ t for t in self.id3 if t not in
                    AudioFile._id3_tag_whitelist ]
        if self.ogg:
            return [ t for t in self.ogg if t not in
                    AudioFile._ogg_tag_whitelist ]

    def dirty(self):
        """Return whether the file will be modified if clean() is called"""
        return bool(self.dirty_containers() or self.dirty_tags())

    def _clean_containers(self):
        cleaned = False
        dirty_containers = self.dirty_containers()
        # TODO: be less brittle.
        if 'APEv2' in dirty_containers:
            self.ape.delete()
            self.ape = None
            cleaned = True
        if 'OggVorbis' in dirty_containers:
            self.ogg.delete()
            self.ogg = None
            cleaned = True
        return cleaned

    def _clean_id3(self):
        dirty_tags = self.dirty_tags()
        if dirty_tags:
            cleaned_comments = False

            for t in dirty_tags:
                del self.id3[t]
                if AudioFile._comment.match(t):
                    cleaned_comments = True

            self.id3.save()

            if cleaned_comments:
                self._warn("removed nonstandard comments")

            return True
        return False

    def _clean_ogg(self):
        dirty_tags = self.dirty_tags()
        if dirty_tags:
            for t in dirty_tags:
                del self.ogg[t]

            self.ogg.save()
            return True
        return False

    def clean(self, preserve_time=False):
        """Remove dirty containers and tags from the file"""

        stat = os.stat(self.filename)

        cleaned = self._clean_containers()
        clean_tags = self._clean_id3 if self.id3 else self._clean_ogg
        if clean_tags():
            cleaned = True

        if preserve_time and cleaned:
            # TODO: setting the atime here is worthless.
            os.utime(self.filename, (stat.st_atime, stat.st_mtime))

        return cleaned
开发者ID:chazomaticus,项目名称:cleantags,代码行数:104,代码来源:cleantags.py


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