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


Python Ref.album方法代码示例

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


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

示例1: test_browse_tracks

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def test_browse_tracks(self):
        def ref(track):
            return Ref.track(name=track.name, uri=track.uri)

        with self.connection as c:
            self.assertEqual(map(ref, self.tracks), schema.browse(
                c, Ref.TRACK
            ))
            self.assertEqual(map(ref, self.tracks[1:2]), schema.browse(
                c, Ref.TRACK, artist=self.artists[0].uri
            ))
            self.assertEqual(map(ref, self.tracks[2:3]), schema.browse(
                c, Ref.TRACK, album=self.albums[0].uri
            ))
            self.assertEqual(map(ref, self.tracks[3:4]), schema.browse(
                c, Ref.TRACK, albumartist=self.artists[0].uri
            ))
            self.assertEqual(map(ref, self.tracks[4:5]), schema.browse(
                c, Ref.TRACK, composer=self.artists[0].uri,
                performer=self.artists[0].uri
            )) 
开发者ID:mopidy,项目名称:mopidy-local-sqlite,代码行数:23,代码来源:test_schema.py

示例2: test_find_includes_fake_artist_and_album_tracks

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def test_find_includes_fake_artist_and_album_tracks(self):
        self.backend.library.dummy_find_exact_result = SearchResult(
            albums=[Album(uri="dummy:album:a", name="A", date="2001")],
            artists=[Artist(uri="dummy:artist:b", name="B")],
            tracks=[Track(uri="dummy:track:c", name="C")],
        )

        self.send_request('find "any" "foo"')

        self.assertInResponse("file: dummy:artist:b")
        self.assertInResponse("Title: Artist: B")

        self.assertInResponse("file: dummy:album:a")
        self.assertInResponse("Title: Album: A")
        self.assertInResponse("Date: 2001")

        self.assertInResponse("file: dummy:track:c")
        self.assertInResponse("Title: C")

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

示例3: test_find_artist_does_not_include_fake_artist_tracks

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def test_find_artist_does_not_include_fake_artist_tracks(self):
        self.backend.library.dummy_find_exact_result = SearchResult(
            albums=[Album(uri="dummy:album:a", name="A", date="2001")],
            artists=[Artist(uri="dummy:artist:b", name="B")],
            tracks=[Track(uri="dummy:track:c", name="C")],
        )

        self.send_request('find "artist" "foo"')

        self.assertNotInResponse("file: dummy:artist:b")
        self.assertNotInResponse("Title: Artist: B")

        self.assertInResponse("file: dummy:album:a")
        self.assertInResponse("Title: Album: A")
        self.assertInResponse("Date: 2001")

        self.assertInResponse("file: dummy:track:c")
        self.assertInResponse("Title: C")

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

示例4: test_find_artist_and_album_does_not_include_fake_tracks

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def test_find_artist_and_album_does_not_include_fake_tracks(self):
        self.backend.library.dummy_find_exact_result = SearchResult(
            albums=[Album(uri="dummy:album:a", name="A", date="2001")],
            artists=[Artist(uri="dummy:artist:b", name="B")],
            tracks=[Track(uri="dummy:track:c", name="C")],
        )

        self.send_request('find "artist" "foo" "album" "bar"')

        self.assertNotInResponse("file: dummy:artist:b")
        self.assertNotInResponse("Title: Artist: B")

        self.assertNotInResponse("file: dummy:album:a")
        self.assertNotInResponse("Title: Album: A")
        self.assertNotInResponse("Date: 2001")

        self.assertInResponse("file: dummy:track:c")
        self.assertInResponse("Title: C")

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

示例5: test_search

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def test_search(self):
        self.backend.library.dummy_search_result = SearchResult(
            albums=[Album(uri="dummy:album:a", name="A")],
            artists=[Artist(uri="dummy:artist:b", name="B")],
            tracks=[Track(uri="dummy:track:c", name="C")],
        )

        self.send_request('search "any" "foo"')

        self.assertInResponse("file: dummy:album:a")
        self.assertInResponse("Title: Album: A")
        self.assertInResponse("file: dummy:artist:b")
        self.assertInResponse("Title: Artist: B")
        self.assertInResponse("file: dummy:track:c")
        self.assertInResponse("Title: C")

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

示例6: test_browse_tracks

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def test_browse_tracks(self):
        def ref(track):
            return Ref.track(name=track.name, uri=track.uri)

        with self.connection as c:
            assert list(map(ref, self.tracks)) == schema.browse(c, Ref.TRACK)
            assert list(map(ref, self.tracks[1:2])) == schema.browse(
                c, Ref.TRACK, artist=self.artists[0].uri
            )
            assert list(map(ref, self.tracks[2:3])) == schema.browse(
                c, Ref.TRACK, album=self.albums[0].uri
            )
            assert list(map(ref, self.tracks[3:4])) == schema.browse(
                c, Ref.TRACK, albumartist=self.artists[0].uri
            )
            assert list(map(ref, self.tracks[4:5])) == schema.browse(
                c,
                Ref.TRACK,
                composer=self.artists[0].uri,
                performer=self.artists[0].uri,
            ) 
开发者ID:mopidy,项目名称:mopidy-local,代码行数:23,代码来源:test_schema.py

示例7: 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

示例8: browse_your_music

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def browse_your_music(self, uri):
        if uri == 'spotifyweb:yourmusic':
            return self._your_music
        if uri == 'spotifyweb:yourmusic:artists':
            return self._cache.sortedArtists
            # return Ref directory with all artists
        elif uri == 'spotifyweb:yourmusic:albums':
            return self._cache.sortedAlbums
            # return Ref directory for all albums
        elif uri.startswith('spotifyweb:yourmusic:artist:'):
            # get artist uri
            return self._cache.artists2albums.get(uri)
            # return Ref directory with all albums for artist
        elif uri.startswith('spotifyweb:yourmusic:album:'):
            # get album uri
            return self._cache.albums2tracks.get(uri)
            # return Ref directory with all tracks for album
        elif uri == 'spotifyweb:yourmusic:songs':
            return self._cache.tracks
        else:
            return [] 
开发者ID:lfcabend,项目名称:mopidy-spotify-web,代码行数:23,代码来源:library.py

示例9: add_album_and_artists

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def add_album_and_artists(self, track):
        album = track.album

        name = album.name
        logger.debug('Going to add album %s', name)
        album_dir = Ref.directory(uri=album.uri, name=name)
        track_ref = Ref.track(name=track.name, uri=track.uri)
        if album.uri not in self.albums2tracks:
            self.sortedAlbums.append(album_dir)

        # adding track to album2tracks
        if album.uri in self.albums2tracks:
            if track_ref not in self.albums2tracks[album.uri]:
                self.albums2tracks[album.uri].append(track_ref)
        else:
            self.albums2tracks[album.uri] = [track_ref]

        if hasattr(track, 'artists'):
            self.add_artists(track, album_dir) 
开发者ID:lfcabend,项目名称:mopidy-spotify-web,代码行数:21,代码来源:library.py

示例10: test_list_distinct

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def test_list_distinct(self):
        self.assertItemsEqual(
            [album.name for album in self.albums],
            schema.list_distinct(self.connection, 'album')
        )
        self.assertItemsEqual(
            [artist.name for artist in self.artists[0:2]],
            schema.list_distinct(self.connection, 'albumartist')
        )
        self.assertItemsEqual(
            [artist.name for artist in self.artists[0:1]],
            schema.list_distinct(self.connection, 'artist')
        )
        self.assertItemsEqual(
            [artist.name for artist in self.artists[0:1]],
            schema.list_distinct(self.connection, 'composer')
        )
        self.assertItemsEqual(
            [artist.name for artist in self.artists[0:1]],
            schema.list_distinct(self.connection, 'performer')
        )
        self.assertItemsEqual(
            [self.tracks[0].date],
            schema.list_distinct(self.connection, 'date')
        )
        self.assertItemsEqual(
            [self.tracks[0].genre],
            schema.list_distinct(self.connection, 'genre')
        ) 
开发者ID:mopidy,项目名称:mopidy-local-sqlite,代码行数:31,代码来源:test_schema.py

示例11: test_browse_albums

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def test_browse_albums(self):
        def ref(album):
            return Ref.album(name=album.name, uri=album.uri)

        with self.connection as c:
            self.assertEqual(map(ref, self.albums), schema.browse(
                c, Ref.ALBUM
            ))
            self.assertEqual(map(ref, []), schema.browse(
                c, Ref.ALBUM, artist=self.artists[0].uri
            ))
            self.assertEqual(map(ref, self.albums[1:2]), schema.browse(
                c, Ref.ALBUM, albumartist=self.artists[0].uri
            )) 
开发者ID:mopidy,项目名称:mopidy-local-sqlite,代码行数:16,代码来源:test_schema.py

示例12: test_delete

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def test_delete(self):
        c = self.connection
        schema.delete_track(c, self.tracks[0].uri)
        schema.cleanup(c)
        self.assertEqual(3, len(c.execute('SELECT * FROM album').fetchall()))
        self.assertEqual(2, len(c.execute('SELECT * FROM artist').fetchall()))

        schema.delete_track(c, self.tracks[1].uri)
        schema.cleanup(c)
        self.assertEqual(3, len(c.execute('SELECT * FROM album').fetchall()))
        self.assertEqual(2, len(c.execute('SELECT * FROM artist').fetchall()))

        schema.delete_track(c, self.tracks[2].uri)
        schema.cleanup(c)
        self.assertEqual(2, len(c.execute('SELECT * FROM album').fetchall()))
        self.assertEqual(2, len(c.execute('SELECT * FROM artist').fetchall()))

        schema.delete_track(c, self.tracks[3].uri)
        schema.cleanup(c)
        self.assertEqual(1, len(c.execute('SELECT * FROM album').fetchall()))
        self.assertEqual(2, len(c.execute('SELECT * FROM artist').fetchall()))

        schema.delete_track(c, self.tracks[4].uri)
        schema.cleanup(c)
        self.assertEqual(0, len(c.execute('SELECT * FROM album').fetchall()))
        self.assertEqual(0, len(c.execute('SELECT * FROM artist').fetchall())) 
开发者ID:mopidy,项目名称:mopidy-local-sqlite,代码行数:28,代码来源:test_schema.py

示例13: test_count_with_multiple_pairs

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def test_count_with_multiple_pairs(self):
        self.send_request('count "artist" "foo" "album" "bar"')
        self.assertInResponse("songs: 0")
        self.assertInResponse("playtime: 0")
        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:7,代码来源:test_music_db.py

示例14: 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.artist(uri="dummy:/artist", name="artist"),
                Ref.playlist(uri="dummy:/pl", name="pl"),
            ],
            "dummy:/foo": [Ref.track(uri="dummy:/foo/b", name="b")],
        }

        self.send_request("listall")

        self.assertInResponse("file: dummy:/a")
        self.assertInResponse("directory: /dummy/foo")
        self.assertInResponse("directory: /dummy/album")
        self.assertInResponse("directory: /dummy/artist")
        self.assertInResponse("directory: /dummy/pl")
        self.assertInResponse("file: dummy:/foo/b")
        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:28,代码来源:test_music_db.py

示例15: test_listallinfo_without_uri

# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import album [as 别名]
def test_listallinfo_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.artist(uri="dummy:/artist", name="artist"),
                Ref.playlist(uri="dummy:/pl", name="pl"),
            ],
            "dummy:/foo": [Ref.track(uri="dummy:/foo/b", name="b")],
        }

        self.send_request("listallinfo")

        self.assertInResponse("file: dummy:/a")
        self.assertInResponse("Title: a")
        self.assertInResponse("directory: /dummy/foo")
        self.assertInResponse("directory: /dummy/album")
        self.assertInResponse("directory: /dummy/artist")
        self.assertInResponse("directory: /dummy/pl")
        self.assertInResponse("file: dummy:/foo/b")
        self.assertInResponse("Title: b")
        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:30,代码来源:test_music_db.py


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