本文整理汇总了Python中mopidy.models.Ref.playlist方法的典型用法代码示例。如果您正苦于以下问题:Python Ref.playlist方法的具体用法?Python Ref.playlist怎么用?Python Ref.playlist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mopidy.models.Ref
的用法示例。
在下文中一共展示了Ref.playlist方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_as_list_with_folders_and_ignored_unloaded_playlist
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import playlist [as 别名]
def test_as_list_with_folders_and_ignored_unloaded_playlist(provider):
result = provider.as_list()
assert len(result) == 2
assert result[0] == Ref.playlist(uri="spotify:user:alice:playlist:foo", name="Foo")
assert result[1] == Ref.playlist(uri="spotify:playlist:bob:baz", name="Bar/Baz (by bob)")
示例2: test_as_list
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import playlist [as 别名]
def test_as_list(self):
result = self.provider.as_list()
self.assertEqual(len(result), 2)
self.assertEqual(
result[0], Ref.playlist(uri='gmusic:playlist:boo', name='boo'))
self.assertEqual(
result[1], Ref.playlist(uri='gmusic:playlist:foo', name='foo'))
示例3: test_path_to_ref
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import playlist [as 别名]
def test_path_to_ref():
from mopidy.m3u.translator import path_to_ref
assert path_to_ref(b'test.m3u') == Ref.playlist(
uri='m3u:test.m3u', name='test'
)
assert path_to_ref(b'Test Playlist.m3u') == Ref.playlist(
uri='m3u:Test%20Playlist.m3u', name='Test Playlist'
)
示例4: test_as_list_with_folders_and_ignored_unloaded_playlist
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import playlist [as 别名]
def test_as_list_with_folders_and_ignored_unloaded_playlist(provider):
result = provider.as_list()
assert len(result) == 3
assert result[0] == Ref.playlist(
uri='spotify:user:alice:starred', name='Starred')
assert result[1] == Ref.playlist(
uri='spotify:user:alice:playlist:foo', name='Foo')
assert result[2] == Ref.playlist(
uri='spotify:playlist:bob:baz', name='Bar/Baz (by bob)')
示例5: spotify_browse_process_results
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import playlist [as 别名]
def spotify_browse_process_results(results):
logger.debug('Processing spotify browse result')
if 'categories' in results:
result_list = results['categories']
browse_uri = 'spotifyweb:browse:categories:'
arr = [Ref.directory(uri=browse_uri + cat['id'],
name=cat['name'])
for cat in result_list['items']]
elif 'playlists' in results:
result_list = results['playlists']
arr = [Ref.playlist(uri=playlist['uri'],
name=playlist['name'])
for playlist in result_list['items']]
elif 'albums' in results:
result_list = results['albums']
arr = [Ref.album(uri=album['uri'],
name=album['name'])
for album in result_list['items']]
else:
result_list = None
arr = []
cont = result_list is not None and result_list['next'] is not None
logger.debug('Spotify browse result cont: %s' % cont)
return arr, cont
示例6: as_list
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import playlist [as 别名]
def as_list(self):
if self._playlists is None:
self.refresh()
logger.debug("Listing TIDAL playlists..")
refs = [Ref.playlist(uri=pl.uri, name=pl.name) for pl in self._playlists.values()]
return sorted(refs, key=operator.attrgetter("name"))
示例7: browse
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import playlist [as 别名]
def browse(self, uri):
logger.debug("Request to browse %s in SpotifyWebLibraryProvider", uri)
if uri == self.root_directory.uri:
return self._root
elif uri == 'spotifyweb:artists':
return self._cache.sortedArtists
# return Ref directory with all artists
elif uri.startswith('spotifyweb:artist:'):
# get artist uri
return self._cache.artists2albums.get(uri)
# return Ref directory with all albums for artist
elif uri.startswith('spotifyweb:album:'):
# get album uri
return self._cache.albums2tracks.get(uri)
# return Ref directory with all tracks for album
elif uri == 'spotifyweb:albums':
return self._cache.sortedAlbums
# return Ref directory for all albums
elif uri.startswith('spotifyweb:featured-playlists') or \
uri.startswith('spotifyweb:new-releases') or \
uri.startswith('spotifyweb:categories') :
ids = uri.split(':')
webapi_url = 'browse/' + '/'.join(ids[1:])
# we browse the /playlists endpoint for categories
if len(ids) == 3 and ids[1] == 'categories':
webapi_url += '/playlists'
try:
offset = 0
arr = []
while True:
results = self.sp_webapi()._get(webapi_url, limit=50, offset=offset)
if results.has_key('categories'):
result_list = results['categories']
arr += [ Ref.directory(uri='spotifyweb:categories:'+cat['id'],
name=cat['name']) for cat in result_list['items']]
elif results.has_key('playlists'):
result_list = results['playlists']
arr += [ Ref.playlist(uri=playlist['uri'],
name=playlist['name']) for playlist in result_list['items']]
elif results.has_key('albums'):
result_list = results['albums']
arr += [ Ref.album(uri=album['uri'],
name=album['name']) for album in result_list['items']]
if result_list['next'] is None:
break
offset = len(arr)
return arr
except spotipy.SpotifyException as e:
logger.info('spotipy called failed')
return []
else:
return []
示例8: test_as_list_when_playlist_container_isnt_loaded
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import playlist [as 别名]
def test_as_list_when_playlist_container_isnt_loaded(
session_mock, provider):
session_mock.playlist_container = None
result = provider.as_list()
assert len(result) == 1
assert result[0] == Ref.playlist(
uri='spotify:user:alice:starred', name='Starred')
示例9: setUp
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import playlist [as 别名]
def setUp(self): # noqa: N802
self.plr1a = Ref.playlist(name='A', uri='dummy1:pl:a')
self.plr1b = Ref.playlist(name='B', uri='dummy1:pl:b')
self.plr2a = Ref.playlist(name='A', uri='dummy2:pl:a')
self.plr2b = Ref.playlist(name='B', uri='dummy2:pl:b')
self.pl1a = Playlist(name='A', tracks=[Track(uri='dummy1:t:a')])
self.pl1b = Playlist(name='B', tracks=[Track(uri='dummy1:t:b')])
self.pl2a = Playlist(name='A', tracks=[Track(uri='dummy2:t:a')])
self.pl2b = Playlist(name='B', tracks=[Track(uri='dummy2:t:b')])
self.sp1 = mock.Mock(spec=backend.PlaylistsProvider)
self.sp1.as_list.return_value.get.return_value = [
self.plr1a, self.plr1b]
self.sp1.lookup.return_value.get.side_effect = [self.pl1a, self.pl1b]
self.sp2 = mock.Mock(spec=backend.PlaylistsProvider)
self.sp2.as_list.return_value.get.return_value = [
self.plr2a, self.plr2b]
self.sp2.lookup.return_value.get.side_effect = [self.pl2a, self.pl2b]
self.backend1 = mock.Mock()
self.backend1.actor_ref.actor_class.__name__ = 'Backend1'
self.backend1.uri_schemes.get.return_value = ['dummy1']
self.backend1.playlists = self.sp1
self.backend2 = mock.Mock()
self.backend2.actor_ref.actor_class.__name__ = 'Backend2'
self.backend2.uri_schemes.get.return_value = ['dummy2']
self.backend2.playlists = self.sp2
# A backend without the optional playlists provider
self.backend3 = mock.Mock()
self.backend3.uri_schemes.get.return_value = ['dummy3']
self.backend3.has_playlists().get.return_value = False
self.backend3.playlists = None
self.core = core.Core(mixer=None, backends=[
self.backend3, self.backend1, self.backend2])
示例10: test
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import playlist [as 别名]
def test(self):
self.backend.library.dummy_browse_result = {
'dummy:/': [Ref.playlist(name='Top 100 tracks', uri='dummy:/1')],
}
self.backend.playlists.set_dummy_playlists([
Playlist(name='Top 100 tracks', uri='dummy:/1'),
])
response1 = self.send_request('lsinfo "/"')
self.send_request('lsinfo "/dummy"')
response2 = self.send_request('lsinfo "/"')
self.assertEqual(response1, response2)
示例11: test
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import playlist [as 别名]
def test(self, last_modified_mock):
last_modified_mock.return_value = '2015-08-05T22:51:06Z'
self.backend.library.dummy_browse_result = {
'dummy:/': [Ref.playlist(name='Top 100 tracks', uri='dummy:/1')],
}
self.backend.playlists.set_dummy_playlists([
Playlist(name='Top 100 tracks', uri='dummy:/1'),
])
response1 = self.send_request('lsinfo "/"')
self.send_request('lsinfo "/dummy"')
response2 = self.send_request('lsinfo "/"')
self.assertEqual(response1, response2)
示例12: test_listall_without_uri
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import playlist [as 别名]
def test_listall_without_uri(self):
tracks = [Track(uri='dummy:/a', name='a'),
Track(uri='dummy:/foo/b', name='b')]
self.backend.library.dummy_library = tracks
self.backend.library.dummy_browse_result = {
'dummy:/': [Ref.track(uri='dummy:/a', name='a'),
Ref.directory(uri='dummy:/foo', name='foo'),
Ref.album(uri='dummy:/album', name='album'),
Ref.playlist(uri='dummy:/pl', name='pl')],
'dummy:/foo': [Ref.track(uri='dummy:/foo/b', name='b')]}
self.sendRequest('listall')
self.assertInResponse('file: dummy:/a')
self.assertInResponse('directory: /dummy/foo')
self.assertInResponse('directory: /dummy/album')
self.assertInResponse('directory: /dummy/pl')
self.assertInResponse('file: dummy:/foo/b')
self.assertInResponse('OK')
示例13: test_listall_without_uri
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import playlist [as 别名]
def test_listall_without_uri(self):
tracks = [Track(uri="dummy:/a", name="a"), Track(uri="dummy:/foo/b", name="b")]
self.backend.library.dummy_library = tracks
self.backend.library.dummy_browse_result = {
"dummy:/": [
Ref.track(uri="dummy:/a", name="a"),
Ref.directory(uri="dummy:/foo", name="foo"),
Ref.album(uri="dummy:/album", name="album"),
Ref.playlist(uri="dummy:/pl", name="pl"),
],
"dummy:/foo": [Ref.track(uri="dummy:/foo/b", name="b")],
}
self.sendRequest("listall")
self.assertInResponse("file: dummy:/a")
self.assertInResponse("directory: /dummy/foo")
self.assertInResponse("directory: /dummy/album")
self.assertInResponse("directory: /dummy/pl")
self.assertInResponse("file: dummy:/foo/b")
self.assertInResponse("OK")
示例14: to_mopidy_playlists
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import playlist [as 别名]
def to_mopidy_playlists(tunigo_playlists):
playlists = []
for playlist in tunigo_playlists:
playlists.append(Ref.playlist(uri=playlist.uri, name=playlist.title))
return playlists
示例15: as_list
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import playlist [as 别名]
def as_list(self):
return [
Ref.playlist(uri=pl.uri, name=pl.name) for pl in self._playlists]