• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python asf.ASF类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mutagen.asf.ASF的典型用法代码示例。如果您正苦于以下问题:Python ASF类的具体用法?Python ASF怎么用?Python ASF使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: _save

    def _save(self, filename, metadata, settings):
        self.log.debug("Saving file %r", filename)
        file = ASF(encode_filename(filename))

        if settings['clear_existing_tags']:
            file.tags.clear()
        if settings['save_images_to_tags']:
            cover = []
            for image in metadata.images:
                if self.config.setting["save_only_front_images_to_tags"] and image["type"] != "front":
                    continue
                imagetype = ID3_IMAGE_TYPE_MAP.get(image["type"], 0)
                tag_data = pack_image(image["mime"], image["data"], imagetype,
                                      image["description"])
                cover.append(ASFByteArrayAttribute(tag_data))
            if cover:
                file.tags['WM/Picture'] = cover

        for name, values in metadata.rawitems():
            if name.startswith('lyrics:'):
                name = 'lyrics'
            elif name == '~rating':
                values[0] = int(values[0]) * 99 / (settings['rating_steps'] - 1)
            if name not in self.__TRANS:
                continue
            name = self.__TRANS[name]
            file.tags[name] = map(unicode, values)
        file.save()
开发者ID:Rawrpwnzl,项目名称:picard,代码行数:28,代码来源:asf.py


示例2: setUp

 def setUp(self):
     fd, self.filename = mkstemp(suffix='wma')
     os.close(fd)
     shutil.copy(self.original, self.filename)
     audio = ASF(self.filename)
     audio["large_value1"] = "#" * 50000
     audio.save()
开发者ID:Shutshutnunte,项目名称:mutagen,代码行数:7,代码来源:test_asf.py


示例3: test_save_large_bytearray

 def test_save_large_bytearray(self):
     audio = ASF(self.filename)
     audio["QL/LargeObject"] = [ASFValue(b"." * (0xFFFF + 1), BYTEARRAY)]
     audio.save()
     self.failIf("QL/LargeObject" in audio.to_extended_content_description)
     self.failIf("QL/LargeObject" in audio.to_metadata)
     self.failIf("QL/LargeObject" not in dict(audio.to_metadata_library))
开发者ID:Shutshutnunte,项目名称:mutagen,代码行数:7,代码来源:test_asf.py


示例4: test_non_text_type

 def test_non_text_type(self):
     audio = ASF(self.filename)
     audio["Author"] = [42]
     audio.save()
     self.assertFalse(audio.to_content_description)
     new = ASF(self.filename)
     self.assertEqual(new["Author"], [42])
开发者ID:Shutshutnunte,项目名称:mutagen,代码行数:7,代码来源:test_asf.py


示例5: TASFIssue29

class TASFIssue29(TestCase):
    original = os.path.join("tests", "data", "issue_29.wma")

    def setUp(self):
        fd, self.filename = mkstemp(suffix='wma')
        os.close(fd)
        shutil.copy(self.original, self.filename)
        self.audio = ASF(self.filename)

    def tearDown(self):
        os.unlink(self.filename)

    def test_pprint(self):
        self.audio.pprint()

    def test_issue_29_description(self):
        self.audio["Description"] = "Hello"
        self.audio.save()
        audio = ASF(self.filename)
        self.failUnless("Description" in audio)
        self.failUnlessEqual(audio["Description"], ["Hello"])
        del(audio["Description"])
        self.failIf("Description" in audio)
        audio.save()
        audio = ASF(self.filename)
        self.failIf("Description" in audio)
开发者ID:Shutshutnunte,项目名称:mutagen,代码行数:26,代码来源:test_asf.py


示例6: _save

    def _save(self, filename, metadata):
        log.debug("Saving file %r", filename)
        file = ASF(encode_filename(filename))

        if config.setting['clear_existing_tags']:
            file.tags.clear()
        cover = []
        for image in metadata.images_to_be_saved_to_tags:
            tag_data = pack_image(image.mimetype, image.data,
                                    image_type_as_id3_num(image.maintype),
                                    image.comment)
            cover.append(ASFByteArrayAttribute(tag_data))
        if cover:
            file.tags['WM/Picture'] = cover

        for name, values in metadata.rawitems():
            if name.startswith('lyrics:'):
                name = 'lyrics'
            elif name == '~rating':
                values[0] = int(values[0]) * 99 / (config.setting['rating_steps'] - 1)
            elif name == 'discnumber' and 'totaldiscs' in metadata:
                values[0] = '%s/%s' % (metadata['discnumber'], metadata['totaldiscs'])
            if name not in self.__TRANS:
                continue
            name = self.__TRANS[name]
            file.tags[name] = map(unicode, values)
        file.save()
开发者ID:LordSputnik,项目名称:picard,代码行数:27,代码来源:asf.py


示例7: _save

    def _save(self, filename, metadata):
        log.debug("Saving file %r", filename)
        file = ASF(encode_filename(filename))

        if config.setting['clear_existing_tags']:
            file.tags.clear()
        if config.setting['save_images_to_tags']:
            cover = []
            for image in metadata.images:
                if not save_this_image_to_tags(image):
                    continue
                tag_data = pack_image(image.mimetype, image.data,
                                      image_type_as_id3_num(image.maintype()),
                                      image.description)
                cover.append(ASFByteArrayAttribute(tag_data))
            if cover:
                file.tags['WM/Picture'] = cover

        for name, values in metadata.rawitems():
            if name.startswith('lyrics:'):
                name = 'lyrics'
            elif name == '~rating':
                values[0] = int(values[0]) * 99 / (config.setting['rating_steps'] - 1)
            if name not in self.__TRANS:
                continue
            name = self.__TRANS[name]
            file.tags[name] = map(unicode, values)
        file.save()
开发者ID:m42i,项目名称:picard,代码行数:28,代码来源:asf.py


示例8: test_save_large_string

 def test_save_large_string(self):
     audio = ASF(self.filename)
     audio["QL/LargeObject"] = [ASFValue("." * 0x7FFF, UNICODE)]
     audio.save()
     self.failIf("QL/LargeObject" in audio.to_extended_content_description)
     self.failIf("QL/LargeObject" in audio.to_metadata)
     self.failIf("QL/LargeObject" not in dict(audio.to_metadata_library))
开发者ID:Shutshutnunte,项目名称:mutagen,代码行数:7,代码来源:test_asf.py


示例9: _save

    def _save(self, filename, metadata):
        log.debug("Saving file %r", filename)
        file = ASF(encode_filename(filename))

        if config.setting["clear_existing_tags"]:
            file.tags.clear()
        if config.setting["save_images_to_tags"]:
            cover = []
            for image in metadata.images:
                if not save_this_image_to_tags(image):
                    continue
                tag_data = pack_image(image["mime"], image["data"], image_type_as_id3_num(image["type"]), image["desc"])
                cover.append(ASFByteArrayAttribute(tag_data))
            if cover:
                file.tags["WM/Picture"] = cover

        for name, values in metadata.rawitems():
            if name.startswith("lyrics:"):
                name = "lyrics"
            elif name == "~rating":
                values[0] = int(values[0]) * 99 / (config.setting["rating_steps"] - 1)
            if name not in self.__TRANS:
                continue
            name = self.__TRANS[name]
            file.tags[name] = map(unicode, values)
        file.save()
开发者ID:TushRaj,项目名称:picard,代码行数:26,代码来源:asf.py


示例10: test_multiple_delete

    def test_multiple_delete(self):
        self.audio["large_value1"] = "#" * 50000
        self.audio.save()

        audio = ASF(self.filename)
        for tag in audio.keys():
            del(audio[tag])
            audio.save()
开发者ID:quodlibet,项目名称:mutagen,代码行数:8,代码来源:test_asf.py


示例11: test_save_guid

 def test_save_guid(self):
     # https://github.com/quodlibet/mutagen/issues/81
     audio = ASF(self.filename)
     audio["QL/GuidObject"] = [ASFValue(b" " * 16, GUID)]
     audio.save()
     self.failIf("QL/GuidObject" in audio.to_extended_content_description)
     self.failIf("QL/GuidObject" in audio.to_metadata)
     self.failIf("QL/GuidObject" not in dict(audio.to_metadata_library))
开发者ID:quodlibet,项目名称:mutagen,代码行数:8,代码来源:test_asf.py


示例12: test_issue_29_description

 def test_issue_29_description(self):
     self.audio["Description"] = "Hello"
     self.audio.save()
     audio = ASF(self.filename)
     self.failUnless("Description" in audio)
     self.failUnlessEqual(audio["Description"], ["Hello"])
     del(audio["Description"])
     self.failIf("Description" in audio)
     audio.save()
     audio = ASF(self.filename)
     self.failIf("Description" in audio)
开发者ID:Shutshutnunte,项目名称:mutagen,代码行数:11,代码来源:test_asf.py


示例13: test_empty

    def test_empty(self):
        audio = ASF(self.filename)
        audio["Author"] = [u"", u""]
        audio["Title"] = [u""]
        audio["Copyright"] = []
        audio.save()

        new = ASF(self.filename)
        self.assertEqual(new["Author"], [u"", u""])
        self.assertEqual(new["Title"], [u""])
        self.assertFalse("Copyright" in new)
开发者ID:Shutshutnunte,项目名称:mutagen,代码行数:11,代码来源:test_asf.py


示例14: test_author_long

    def test_author_long(self):
        audio = ASF(self.filename)
        # 2 ** 16 - 2 bytes encoded text + 2 bytes termination
        just_small_enough = u"a" * (((2 ** 16) // 2) - 2)
        audio["Author"] = [just_small_enough]
        audio.save()
        self.assertTrue(audio.to_content_description)
        self.assertFalse(audio.to_metadata_library)

        audio["Author"] = [just_small_enough + u"a"]
        audio.save()
        self.assertFalse(audio.to_content_description)
        self.assertTrue(audio.to_metadata_library)
开发者ID:Shutshutnunte,项目名称:mutagen,代码行数:13,代码来源:test_asf.py


示例15: test_author

    def test_author(self):
        audio = ASF(self.filename)
        values = [u"Foo", u"Bar", u"Baz"]
        audio["Author"] = values
        audio.save()
        self.assertEqual(
            list(audio.to_content_description.items()), [(u"Author", u"Foo")])
        self.assertEqual(
            audio.to_metadata_library,
            [(u"Author", u"Bar"), (u"Author", u"Baz")])

        new = ASF(self.filename)
        self.assertEqual(new["Author"], values)
开发者ID:Shutshutnunte,项目名称:mutagen,代码行数:13,代码来源:test_asf.py


示例16: __collect_stats_wma

    def __collect_stats_wma(self):
        """
        Process a WMA file to grab meta-data from it
        """
        for file in self.music_files['wma']:
            try:
                asf = ASF(file)

                artist = unicode(asf.get('WM/AlbumArtist', ['Unknown Artist'])[0]).lower()
                song   = unicode(asf.get('Title', ['Unknown Title'])[0]).lower()
                album  = unicode(asf.get('WM/AlbumTitle', ['Unknown Album'])[0]).lower()

                self.__add_stats(artist, album, song)
            except Exception as e:
                print("Error: "+str(e))
                print("File: "+file)
开发者ID:travishathaway,项目名称:small-stuff,代码行数:16,代码来源:utilities.py


示例17: test_padding

    def test_padding(self):
        old_tags = sorted(self.audio.items())

        def get_padding(fn):
            header = ASF(fn)._header
            return len(header.get_child(PaddingObject.GUID).data)

        for i in [0, 1, 2, 3, 42, 100, 5000, 30432, 1]:

            def padding_cb(info):
                self.assertEqual(info.size, 30432)
                return i

            self.audio.save(padding=padding_cb)
            self.assertEqual(get_padding(self.filename), i)

        last = ASF(self.filename)
        self.assertEqual(sorted(last.items()), old_tags)
开发者ID:quodlibet,项目名称:mutagen,代码行数:18,代码来源:test_asf.py


示例18: set_key

 def set_key(self, key, value, result=None):
     self.audio[key] = value
     self.audio.save()
     self.audio = ASF(self.audio.filename)
     self.failUnless(key in self.audio)
     newvalue = self.audio[key]
     if isinstance(newvalue, list):
         for a, b in zip(sorted(newvalue), sorted(result or value)):
             self.failUnlessEqual(a, b)
     else:
         self.failUnlessEqual(audio[key], result or value)
开发者ID:hchapman,项目名称:mutagen,代码行数:11,代码来源:test_asf.py


示例19: test_stream

 def test_stream(self):
     self.audio["QL/OneHasStream"] = [ASFValue("Whee", UNICODE, stream=2), ASFValue("Whee", UNICODE)]
     self.audio["QL/AllHaveStream"] = [ASFValue("Whee", UNICODE, stream=1), ASFValue("Whee", UNICODE, stream=2)]
     self.audio["QL/NoStream"] = ASFValue("Whee", UNICODE)
     self.audio.save()
     self.audio = ASF(self.audio.filename)
     self.failUnlessEqual(self.audio["QL/NoStream"][0].stream, None)
     self.failUnlessEqual(self.audio["QL/OneHasStream"][0].stream, 2)
     self.failUnlessEqual(self.audio["QL/OneHasStream"][1].stream, None)
     self.failUnlessEqual(self.audio["QL/AllHaveStream"][0].stream, 1)
     self.failUnlessEqual(self.audio["QL/AllHaveStream"][1].stream, 2)
开发者ID:Sophist-UK,项目名称:mutagen,代码行数:11,代码来源:test_asf.py


示例20: test_language

 def test_language(self):
     self.failIf("QL/OneHasLang" in self.audio)
     self.failIf("QL/AllHaveLang" in self.audio)
     self.audio["QL/OneHasLang"] = [ASFValue("Whee", UNICODE, language=2), ASFValue("Whee", UNICODE)]
     self.audio["QL/AllHaveLang"] = [ASFValue("Whee", UNICODE, language=1), ASFValue("Whee", UNICODE, language=2)]
     self.audio["QL/NoLang"] = ASFValue("Whee", UNICODE)
     self.audio.save()
     self.audio = ASF(self.audio.filename)
     self.failUnlessEqual(self.audio["QL/NoLang"][0].language, None)
     self.failUnlessEqual(self.audio["QL/OneHasLang"][0].language, 2)
     self.failUnlessEqual(self.audio["QL/OneHasLang"][1].language, None)
     self.failUnlessEqual(self.audio["QL/AllHaveLang"][0].language, 1)
     self.failUnlessEqual(self.audio["QL/AllHaveLang"][1].language, 2)
开发者ID:Sophist-UK,项目名称:mutagen,代码行数:13,代码来源:test_asf.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python flac.to_int_be函数代码示例发布时间:2022-05-27
下一篇:
Python _vorbis.istag函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap