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


Python models.Playlist方法代码示例

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


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

示例1: test_listplaylistinfo

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Playlist [as 别名]
def test_listplaylistinfo(self):
        tracks = [
            Track(uri="dummy:a", name="Track A", length=5000),
            Track(uri="dummy:é", name="Track é", length=5000),
        ]
        self.backend.library.dummy_library = tracks
        self.backend.playlists.set_dummy_playlists(
            [Playlist(name="name", uri="dummy:name", tracks=tracks)]
        )

        self.send_request('listplaylistinfo "name"')

        self.assertInResponse("file: dummy:a")
        self.assertInResponse("Title: Track A")
        self.assertInResponse("Time: 5")
        self.assertInResponse("file: dummy:é")
        self.assertInResponse("Title: Track é")
        self.assertNotInResponse("Track: 0")
        self.assertNotInResponse("Pos: 0")
        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:22,代码来源:test_stored_playlists.py

示例2: test_listplaylistinfo_duplicate

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Playlist [as 别名]
def test_listplaylistinfo_duplicate(self):
        tracks = [
            Track(uri="dummy:b"),
            Track(uri="dummy:c"),
        ]
        self.backend.library.dummy_library = tracks
        playlist1 = Playlist(name="a", uri="dummy:a1", tracks=tracks[:1])
        playlist2 = Playlist(name="a", uri="dummy:a2", tracks=tracks[1:])
        self.backend.playlists.set_dummy_playlists([playlist1, playlist2])

        self.send_request('listplaylistinfo "a [2]"')

        self.assertInResponse("file: dummy:c")
        self.assertNotInResponse("Track: 0")
        self.assertNotInResponse("Pos: 0")
        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:18,代码来源:test_stored_playlists.py

示例3: test_listplaylists

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Playlist [as 别名]
def test_listplaylists(self, last_modified_mock):
        last_modified_mock.return_value = "2015-08-05T22:51:06Z"
        self.backend.playlists.set_dummy_playlists(
            [
                Playlist(name="a", uri="dummy:a"),
                Playlist(name="é", uri="dummy:é"),
            ]
        )

        self.send_request("listplaylists")

        self.assertInResponse("playlist: a")
        self.assertInResponse("playlist: é")
        # Date without milliseconds and with time zone information
        self.assertInResponse("Last-Modified: 2015-08-05T22:51:06Z")
        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:18,代码来源:test_stored_playlists.py

示例4: test_load_with_range_loads_part_of_playlist

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Playlist [as 别名]
def test_load_with_range_loads_part_of_playlist(self):
        tracks = [
            Track(uri="dummy:a"),
            Track(uri="dummy:b"),
            Track(uri="dummy:c"),
            Track(uri="dummy:d"),
            Track(uri="dummy:e"),
        ]
        self.backend.library.dummy_library = tracks
        self.core.tracklist.add(uris=["dummy:a", "dummy:b"]).get()

        assert len(self.core.tracklist.get_tracks().get()) == 2
        self.backend.playlists.set_dummy_playlists(
            [Playlist(name="A-list", uri="dummy:A-list", tracks=tracks[2:])]
        )

        self.send_request('load "A-list" "1:2"')

        tracks = self.core.tracklist.get_tracks().get()
        assert 3 == len(tracks)
        assert "dummy:a" == tracks[0].uri
        assert "dummy:b" == tracks[1].uri
        assert "dummy:d" == tracks[2].uri
        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:26,代码来源:test_stored_playlists.py

示例5: test_load_with_range_without_end_loads_rest_of_playlist

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Playlist [as 别名]
def test_load_with_range_without_end_loads_rest_of_playlist(self):
        tracks = [
            Track(uri="dummy:a"),
            Track(uri="dummy:b"),
            Track(uri="dummy:c"),
            Track(uri="dummy:d"),
            Track(uri="dummy:e"),
        ]
        self.backend.library.dummy_library = tracks
        self.core.tracklist.add(uris=["dummy:a", "dummy:b"]).get()

        assert len(self.core.tracklist.get_tracks().get()) == 2
        self.backend.playlists.set_dummy_playlists(
            [Playlist(name="A-list", uri="dummy:A-list", tracks=tracks[2:])]
        )

        self.send_request('load "A-list" "1:"')

        tracks = self.core.tracklist.get_tracks().get()
        assert 4 == len(tracks)
        assert "dummy:a" == tracks[0].uri
        assert "dummy:b" == tracks[1].uri
        assert "dummy:d" == tracks[2].uri
        assert "dummy:e" == tracks[3].uri
        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:27,代码来源:test_stored_playlists.py

示例6: test_load_full_track_metadata

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Playlist [as 别名]
def test_load_full_track_metadata(self):
        tracks = [
            Track(uri="dummy:a", name="Track A", length=5000),
        ]
        self.backend.library.dummy_library = tracks
        self.backend.playlists.set_dummy_playlists(
            [
                Playlist(
                    name="A-list", uri="dummy:a1", tracks=[Track(uri="dummy:a")]
                )
            ]
        )

        self.send_request('load "A-list"')

        tracks = self.core.tracklist.get_tracks().get()
        assert len(tracks) == 1
        assert tracks[0].uri == "dummy:a"
        assert tracks[0].name == "Track A"
        assert tracks[0].length == 5000

        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:24,代码来源:test_stored_playlists.py

示例7: test_playlistdelete_save_fails

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Playlist [as 别名]
def test_playlistdelete_save_fails(self):
        tracks = [
            Track(uri="dummy:a"),
            Track(uri="dummy:b"),
            Track(uri="dummy:c"),
        ]  # len() == 3
        self.backend.playlists.set_dummy_playlists(
            [Playlist(name="name", uri="dummy:a1", tracks=tracks)]
        )
        self.backend.playlists.set_allow_save(False)

        self.send_request('playlistdelete "name" "2"')

        self.assertInResponse(
            "ACK [0@0] {playlistdelete} Backend with "
            'scheme "dummy" failed to save playlist'
        ) 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:19,代码来源:test_stored_playlists.py

示例8: test_playlistmove

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Playlist [as 别名]
def test_playlistmove(self):
        tracks = [
            Track(uri="dummy:a"),
            Track(uri="dummy:b"),
            Track(uri="dummy:c"),  # this one is getting moved to top
        ]
        self.backend.playlists.set_dummy_playlists(
            [Playlist(name="namé", uri="dummy:a1", tracks=tracks)]
        )

        self.send_request('playlistmove "namé" "2" "0"')

        self.assertInResponse("OK")
        assert (
            "dummy:c"
            == self.backend.playlists.get_items("dummy:a1").get()[0].uri
        ) 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:19,代码来源:test_stored_playlists.py

示例9: test_playlistmove_save_fails

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Playlist [as 别名]
def test_playlistmove_save_fails(self):
        tracks = [
            Track(uri="dummy:a"),
            Track(uri="dummy:b"),
            Track(uri="dummy:c"),  # this one is getting moved to top
        ]
        self.backend.playlists.set_dummy_playlists(
            [Playlist(name="name", uri="dummy:a1", tracks=tracks)]
        )
        self.backend.playlists.set_allow_save(False)

        self.send_request('playlistmove "name" "2" "0"')

        self.assertInResponse(
            "ACK [0@0] {playlistmove} Backend with "
            'scheme "dummy" failed to save playlist'
        ) 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:19,代码来源:test_stored_playlists.py

示例10: get_items

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Playlist [as 别名]
def get_items(self, uri):
        '''Get the items in a playlist specified by uri.

        Returns a list of Ref objects referring to the playlist’s items.

        If a playlist with the given uri doesn’t exist, it returns None.


          Return type:	list of mopidy.models.Ref, or None

        '''
        logger.debug('Playlist: get_items %r', uri)
        _rx = re.compile(r'plex:playlist:(?P<plid>\d+)').match(uri)
        if _rx is None:
            return None

        def wrap_ref(item):
            return Ref.track(uri='plex:track:{}'.format(item.ratingKey), name=item.title)

        return [wrap_ref(item) for item in
                listItems(self.plex, '/playlists/{}/items'.format(_rx.group('plid')))] 
开发者ID:havardgulldahl,项目名称:mopidy_plex,代码行数:23,代码来源:playlists.py

示例11: lookup

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Playlist [as 别名]
def lookup(self, uri):
        '''Lookup playlist with given URI in both the set of playlists and in any other playlist source.

        Returns the playlists or None if not found.


          Parameters:	uri (string) – playlist URI
          Return type:	mopidy.models.Playlist or None

        '''
        logger.debug('Playlist: lookup %r', uri)
        _rx = re.compile(r'plex:playlist:(?P<plid>\d+)').match(uri)
        if _rx is None:
            return None
        plexlist = listItems(self.plex, '/playlists/{:s}'.format(_rx.group('plid')))[0]
        PL = Playlist(uri=uri,
                      name=plexlist.title,
                      tracks=[wrap_track(_t, self.backend.plex_uri) for _t in plexlist.items()],
                      last_modified=None, # TODO: find this value
                     )
        return PL 
开发者ID:havardgulldahl,项目名称:mopidy_plex,代码行数:23,代码来源:playlists.py

示例12: refresh

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Playlist [as 别名]
def refresh(self):
        logger.debug("Refreshing TIDAL playlists..")
        playlists = {}
        session = self.backend._session

        plists = session.user.favorites.playlists()
        for pl in plists:
            pl.name = "* " + pl.name
        # Append favourites to end to keep the tagged name if there are
        # duplicates
        plists = session.user.playlists() + plists

        for pl in plists:
            uri = "tidal:playlist:" + pl.id
            pl_tracks = session.get_playlist_tracks(pl.id)
            tracks = full_models_mappers.create_mopidy_tracks(pl_tracks)
            playlists[uri] = Playlist(uri=uri,
                                      name=pl.name,
                                      tracks=tracks,
                                      last_modified=pl.last_updated)

        self._playlists = playlists
        backend.BackendListener.send('playlists_loaded') 
开发者ID:tehkillerbee,项目名称:mopidy-tidal,代码行数:25,代码来源:playlists.py

示例13: test_lsinfo_without_path_returns_same_as_for_root

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Playlist [as 别名]
def test_lsinfo_without_path_returns_same_as_for_root(
        self, last_modified_mock
    ):
        last_modified_mock.return_value = "2015-08-05T22:51:06Z"
        self.backend.playlists.set_dummy_playlists(
            [Playlist(name="a", uri="dummy:/a")]
        )

        response1 = self.send_request("lsinfo")
        response2 = self.send_request('lsinfo "/"')
        assert response1 == response2 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:13,代码来源:test_music_db.py

示例14: test_lsinfo_with_empty_path_returns_same_as_for_root

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Playlist [as 别名]
def test_lsinfo_with_empty_path_returns_same_as_for_root(
        self, last_modified_mock
    ):
        last_modified_mock.return_value = "2015-08-05T22:51:06Z"
        self.backend.playlists.set_dummy_playlists(
            [Playlist(name="a", uri="dummy:/a")]
        )

        response1 = self.send_request('lsinfo ""')
        response2 = self.send_request('lsinfo "/"')
        assert response1 == response2 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:13,代码来源:test_music_db.py

示例15: test_lsinfo_for_root_includes_playlists

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Playlist [as 别名]
def test_lsinfo_for_root_includes_playlists(self, last_modified_mock):
        last_modified_mock.return_value = "2015-08-05T22:51:06Z"
        self.backend.playlists.set_dummy_playlists(
            [Playlist(name="a", uri="dummy:/a")]
        )

        self.send_request('lsinfo "/"')
        self.assertInResponse("playlist: a")
        self.assertInResponse("Last-Modified: 2015-08-05T22:51:06Z")
        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:12,代码来源:test_music_db.py


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