本文整理匯總了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")
示例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")
示例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")
示例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")
示例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")
示例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")
示例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'
)
示例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
)
示例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'
)
示例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')))]
示例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
示例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')
示例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
示例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
示例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")