本文整理汇总了Python中mopidy.models.Ref.track方法的典型用法代码示例。如果您正苦于以下问题:Python Ref.track方法的具体用法?Python Ref.track怎么用?Python Ref.track使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mopidy.models.Ref
的用法示例。
在下文中一共展示了Ref.track方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fulltext_search
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def test_fulltext_search(self):
for results, query, filters in [
(
map(lambda t: t.uri, self.tracks),
[('track_name', 'track')],
[]
),
(
[self.tracks[1].uri, self.tracks[3].uri],
[('track_name', 'track')],
[{'artist': self.artists[0].uri}, {'albumartist': self.artists[0].uri}] # noqa
),
]:
with self.connection as c:
tracks = schema.search_tracks(c, query, 10, 0, False, filters)
self.assertItemsEqual(results, map(lambda t: t.uri, tracks))
示例2: test_browse_tracks
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [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
))
示例3: test_count_correct_length
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def test_count_correct_length(self):
# Count the lone track
self.backend.library.dummy_find_exact_result = SearchResult(
tracks=[Track(uri="dummy:a", name="foo", date="2001", length=4000)]
)
self.send_request('count "title" "foo"')
self.assertInResponse("songs: 1")
self.assertInResponse("playtime: 4")
self.assertInResponse("OK")
# Count multiple tracks
self.backend.library.dummy_find_exact_result = SearchResult(
tracks=[
Track(uri="dummy:b", date="2001", length=50000),
Track(uri="dummy:c", date="2001", length=600000),
]
)
self.send_request('count "date" "2001"')
self.assertInResponse("songs: 2")
self.assertInResponse("playtime: 650")
self.assertInResponse("OK")
示例4: test_listall_with_uri
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def test_listall_with_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"),
],
"dummy:/foo": [Ref.track(uri="dummy:/foo/b", name="b")],
}
self.send_request('listall "/dummy/foo"')
self.assertNotInResponse("file: dummy:/a")
self.assertInResponse("directory: /dummy/foo")
self.assertInResponse("file: dummy:/foo/b")
self.assertInResponse("OK")
示例5: test_listallinfo_with_uri
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def test_listallinfo_with_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"),
],
"dummy:/foo": [Ref.track(uri="dummy:/foo/b", name="b")],
}
self.send_request('listallinfo "/dummy/foo"')
self.assertNotInResponse("file: dummy:/a")
self.assertNotInResponse("Title: a")
self.assertInResponse("directory: /dummy/foo")
self.assertInResponse("file: dummy:/foo/b")
self.assertInResponse("Title: b")
self.assertInResponse("OK")
示例6: test_find_includes_fake_artist_and_album_tracks
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [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")
示例7: test_find_artist_does_not_include_fake_artist_tracks
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [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")
示例8: test_find_albumartist_does_not_include_fake_artist_tracks
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def test_find_albumartist_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 "albumartist" "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")
示例9: test_find_artist_and_album_does_not_include_fake_tracks
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [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")
示例10: test_search
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [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")
示例11: test_browse_tracks
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [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,
)
示例12: add_album_and_artists
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [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)
示例13: save
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def save(self, playlist):
# Update modifications to the playlist in the Jellyfin server
playlist_id = playlist.uri.split(':')[-1]
# Get the list of Jellyfin Ids for each track of the playlist
new_track_ids = [
i.uri.split(':')[-1] for i in playlist.tracks
]
self.backend.remote.update_playlist(
playlist_id, new_track_ids
)
# Update the playlist views
self.refresh()
return playlist
示例14: setUp
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def setUp(self):
self.connection = sqlite3.connect(DBPATH, factory=schema.Connection)
schema.load(self.connection)
for track in self.tracks:
schema.insert_track(self.connection, track)
示例15: test_lookup_track
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def test_lookup_track(self):
with self.connection as c:
for track in self.tracks:
result = schema.lookup(c, Ref.TRACK, track.uri)
self.assertEqual([track], list(result))