本文整理汇总了Python中mopidy.models.Ref.album方法的典型用法代码示例。如果您正苦于以下问题:Python Ref.album方法的具体用法?Python Ref.album怎么用?Python Ref.album使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mopidy.models.Ref
的用法示例。
在下文中一共展示了Ref.album方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_browse_charts
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def test_browse_charts(config, library, genres, charts, lookup):
responses.add(responses.GET, re.compile(r'.*/genres\b.*'), json=genres)
responses.add(responses.GET, re.compile(r'.*/charts\b.*'), json=charts)
responses.add(responses.GET, re.compile(r'.*/lookup\b.*'), json=lookup)
assert library.browse('podcast+itunes:charts:1000') == [
Ref.album(name='foo', uri='podcast+http://example.com/1234'),
Ref.album(name='bar', uri='podcast+http://example.com/5678')
]
示例2: spotify_browse_process_results
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [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
示例3: ref
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def ref(obj, uri=uri):
identifier = obj['identifier']
mediatype = obj['mediatype']
if mediatype == 'collection':
return Ref.directory(name=name(obj), uri=uri(identifier))
else:
return Ref.album(name=name(obj), uri=uri(identifier))
示例4: test_album_ref
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def test_album_ref():
assert translator.ref({
'DisplayName': 'Foo',
'URI': BASEURI + '/foo',
'Type': 'container',
'TypeEx': ALBUM_TYPE
}) == Ref.album(uri=BASEURI+'/foo', name='Foo')
示例5: _ref
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def _ref(metadata):
identifier = metadata['identifier']
uri = uritools.uricompose(SCHEME, path=identifier)
name = metadata.get('title', identifier)
if metadata.get('mediatype', 'collection') == 'collection':
return Ref.directory(uri=uri, name=name)
else:
return Ref.album(uri=uri, name=name)
示例6: spotify_albums_results
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def spotify_albums_results(results):
logger.debug('Processing spotify albums result')
albums = [Ref.album(uri=album['uri'],
name=album['name'])
for album in results['items']]
logger.debug('Processing spotify albums result; next %s' % results['next'])
cont = results['next'] is not None
logger.debug('Spotify get albums result cont: %s' % cont)
return albums, cont
示例7: browse
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [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: browse
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def browse(self, uri):
logger.debug(u"Browse being called for %s" % uri)
level = urisplit(uri).path
query = self._sanitize_query(dict(urisplit(uri).getquerylist()))
logger.debug("Got parsed to level: %s - query: %s" % (level,
query))
result = []
if not level:
logger.error("No level for uri %s" % uri)
# import pdb; pdb.set_trace()
if level == 'root':
for row in self._browse_genre():
result.append(Ref.directory(
uri=uricompose('beetslocal',
None,
'genre',
dict(genre=row[0])),
name=row[0] if bool(row[0]) else u'No Genre'))
elif level == "genre":
# artist refs not browsable via mpd
for row in self._browse_artist(query):
result.append(Ref.directory(
uri=uricompose('beetslocal',
None,
'artist',
dict(genre=query['genre'][0],
artist=row[1])),
name=row[0] if bool(row[0]) else u'No Artist'))
elif level == "artist":
for album in self._browse_album(query):
result.append(Ref.album(
uri=uricompose('beetslocal',
None,
'album',
dict(album=album.id)),
name=album.album))
elif level == "album":
for track in self._browse_track(query):
result.append(Ref.track(
uri="beetslocal:track:%s:%s" % (
track.id,
uriencode(track.path, '/')),
name=track.title))
else:
logger.debug('Unknown URI: %s', uri)
# logger.debug(result)
return result
示例9: test_listall_without_uri
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [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')
示例10: test_listall_without_uri
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [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")
示例11: releases_to_mopidy_albums
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def releases_to_mopidy_albums(tunigo_releases):
releases = []
for release in tunigo_releases:
name = '{} - {}'.format(release.artist_name, release.album_name)
releases.append(Ref.album(uri=release.uri, name=name))
return releases
示例12: ref
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def ref(album):
return Ref.album(name=album.name, uri=album.uri)
示例13: test_album_constructor
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def test_album_constructor(self):
ref = Ref.album(uri='foo', name='bar')
self.assertEqual(ref.uri, 'foo')
self.assertEqual(ref.name, 'bar')
self.assertEqual(ref.type, Ref.ALBUM)
示例14: create_album
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def create_album(tidal_album):
return Ref.album(uri="tidal:album:" + str(tidal_album.id),
name=tidal_album.name)