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


Python Ref.album方法代码示例

本文整理汇总了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')
    ]
开发者ID:eliassoares,项目名称:mopidy-podcast-itunes,代码行数:10,代码来源:test_browse.py

示例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
开发者ID:lfcabend,项目名称:mopidy-spotify-web,代码行数:27,代码来源:library.py

示例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))
开发者ID:tkem,项目名称:mopidy-internetarchive,代码行数:9,代码来源:translator.py

示例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')
开发者ID:anthonydahanne,项目名称:mopidy-dleyna,代码行数:9,代码来源:test_translator.py

示例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)
开发者ID:Neoheurist,项目名称:mopidy-internetarchive,代码行数:10,代码来源:library.py

示例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
开发者ID:lfcabend,项目名称:mopidy-spotify-web,代码行数:11,代码来源:library.py

示例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 []
开发者ID:fredericgermain,项目名称:mopidy-spotify-web,代码行数:59,代码来源:library.py

示例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
开发者ID:rawdlite,项目名称:mopidy-beets-local,代码行数:49,代码来源:library.py

示例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')
开发者ID:AndroidMarv,项目名称:mopidy,代码行数:21,代码来源:test_music_db.py

示例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")
开发者ID:valentinb,项目名称:mopidy,代码行数:23,代码来源:test_music_db.py

示例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
开发者ID:ThommyH,项目名称:mopidy-spotify-tunigo,代码行数:8,代码来源:translator.py

示例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)
开发者ID:mopidy,项目名称:mopidy-local-sqlite,代码行数:4,代码来源:test_schema.py

示例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)
开发者ID:AddBassStudios,项目名称:mopidy,代码行数:7,代码来源:test_models.py

示例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)
开发者ID:mones88,项目名称:mopidy-tidal,代码行数:5,代码来源:ref_models_mappers.py


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