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


Python CoverManager.search_cover方法代码示例

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


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

示例1: test_search

# 需要导入模块: from quodlibet.util.cover.manager import CoverManager [as 别名]
# 或者: from quodlibet.util.cover.manager.CoverManager import search_cover [as 别名]
    def test_search(self):
        manager = CoverManager(use_built_in=False)
        handler = manager.plugin_handler
        for source in dummy_sources:
            handler.plugin_handle(source)
            handler.plugin_enable(source)
            source.cls.cover_call = False
            source.cls.fetch_call = False

        song = AudioFile({
            "~filename": os.path.join("/tmp/asong.ogg"),
            "album": "Abbey Road",
            "artist": "The Beatles"
        })
        songs = [song]
        results = []

        def done(manager, provider, result):
            self.failUnless(result, msg="Shouldn't succeed with no results")
            results.append(result)

        def finished(manager, songs):
            print("Finished!")

        manager.connect('covers-found', done)
        manager.search_cover(Cancellable(), songs)
        manager.connect('searches-complete', finished)
        run_loop()

        self.failUnlessEqual(len(results), 1)
开发者ID:LudoBike,项目名称:quodlibet,代码行数:32,代码来源:test_plugins_cover.py

示例2: TCoverManager

# 需要导入模块: from quodlibet.util.cover.manager import CoverManager [as 别名]
# 或者: from quodlibet.util.cover.manager.CoverManager import search_cover [as 别名]

#.........这里部分代码省略.........
        # The glob in the dirname should be ignored, while the
        # glob in the filename/basename is honored
        assert path_equal(
            os.path.abspath(self._find_cover(self.song).name), f)

        self.song['~filename'] = old_song_path

    def test_intelligent(self):
        song = self.song
        song["artist"] = "Q-Man"
        song["title"] = "First Q falls hardest"
        fns = ["Quuxly - back.jpg", "Quuxly.jpg", "q-man - quxxly.jpg",
                  "folder.jpeg", "Q-man - Quuxly (FRONT).jpg"]
        for fn in fns:
            f = self.add_file(fn)
            cover = self._find_cover(song)
            if cover:
                actual = os.path.abspath(cover.name)
                assert path_equal(actual, f)
            else:
                # Here, no cover is better than the back...
                assert path_equal(f, self.full_path("Quuxly - back.jpg"))

    def test_embedded_special_cover_words(self):
        """Tests that words incidentally containing embedded "special" words
        album keywords (e.g. cover, disc, back) don't trigger
        See Issue 818"""

        song = AudioFile({
            "~filename": fsnative(os.path.join(self.dir, u"asong.ogg")),
            "album": "foobar",
            "title": "Ode to Baz",
            "artist": "Q-Man",
        })
        data = [('back.jpg', False),
                ('discovery.jpg', False),
                ("Pharell - frontin'.jpg", False),
                ('nickelback - Curb.jpg', False),
                ('foobar.jpg', True),
                ('folder.jpg', True),  # Though this order is debatable
                ('Q-Man - foobar.jpg', True),
                ('Q-man - foobar (cover).jpg', True)]
        for fn, should_find in data:
            f = self.add_file(fn)
            cover = self._find_cover(song)
            if cover:
                actual = os.path.abspath(cover.name)
                assert path_equal(
                    actual, f, "\"%s\" should trump \"%s\"" % (f, actual))
            else:
                self.failIf(should_find, msg="Couldn't find %s for %s" %
                                             (f, song("~filename")))

    def add_file(self, fn):
        f = self.full_path(fn)
        open(f, "wb").close()
        return f

    def test_multiple_people(self):
        song = AudioFile({
            "~filename": os.path.join(self.dir, "asong.ogg"),
            "album": "foobar",
            "title": "Ode to Baz",
            "performer": "The Performer",
            "artist": "The Composer\nThe Conductor",
            "composer": "The Composer",
        })
        for fn in ["foobar.jpg",
                   "The Performer - foobar.jpg",
                   "The Composer - The Performer - foobar.jpg",
                   "The Composer - The Conductor, The Performer - foobar.jpg"]:
            f = self.add_file(fn)
            cover = self._find_cover(song)
            self.failUnless(cover)
            actual = os.path.abspath(cover.name)
            cover.close()
            assert path_equal(
                actual, f, "\"%s\" should trump \"%s\"" % (f, actual))

    def test_get_thumbnail(self):
        self.assertTrue(self.manager.get_pixbuf(self.song, 10, 10) is None)
        self.assertTrue(
            self.manager.get_pixbuf_many([self.song], 10, 10) is None)

    def test_get_many(self):
        songs = [AudioFile({"~filename": os.path.join(self.dir, "song.ogg"),
                            "title": "Ode to Baz"}),
                 self.an_album_song()]
        plugin = Plugin(ArtworkUrlCover)
        self.manager.plugin_handler.plugin_enable(plugin)
        self.add_file('cover.jpg')
        cover = self.manager.get_cover_many(songs)
        assert cover

    def test_search_missing_artist(self):
        titled_album_song = self.an_album_song('z.ogg')
        titled_album_song["artist"] = "foo"
        album_songs = [self.an_album_song('x.ogg'), titled_album_song,
                       self.an_album_song()]
        self.manager.search_cover(Gio.Cancellable(), album_songs)
开发者ID:LudoBike,项目名称:quodlibet,代码行数:104,代码来源:test_util_cover.py


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