本文整理汇总了Python中spotify.Link.from_album方法的典型用法代码示例。如果您正苦于以下问题:Python Link.from_album方法的具体用法?Python Link.from_album怎么用?Python Link.from_album使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spotify.Link
的用法示例。
在下文中一共展示了Link.from_album方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: action_search
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_album [as 别名]
def action_search(self, line):
if not line:
if self.results is False:
print "No search is in progress"
return False
elif self.results is None:
print "Searching is in progress"
else:
print "Artists:"
for a in self.results.artists():
print " ", Link.from_artist(a), a.name()
print "Albums:"
for a in self.results.albums():
print " ", Link.from_album(a), a.name()
print "Tracks:"
for a in self.results.tracks():
print " ", Link.from_track(a, 0), a.name()
print self.results.total_tracks() - len(self.results.tracks()), "Tracks not shown"
self.results = False
else:
self.results = None
def _(results, userdata):
print "\nSearch results received"
self.results = results
self.search(line, _)
示例2: do_search
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_album [as 别名]
def do_search(self, line):
if not line:
if self.results is False:
print "No search is in progress"
elif self.results is None:
print "Searching is in progress"
else:
print "Artists:"
for a in self.results.artists():
print " ", Link.from_artist(a), a.name()
print "Albums:"
for a in self.results.albums():
print " ", Link.from_album(a), a.name()
print "Tracks:"
for a in self.results.tracks():
print " ", Link.from_track(a, 0), a.name()
print self.results.total_tracks() - \
len(self.results.tracks()), "Tracks not shown"
else:
line = line.decode('utf-8')
self.results = None
def search_finished(results, userdata):
print "\nSearch results received"
self.results = results
self.print_search_results()
self.jukebox.search(line, search_finished)
示例3: create_album_object
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_album [as 别名]
def create_album_object(self, album):
''' Factory method for album objects '''
album_uri = str(Link.from_album(album))
title = album.name().decode("utf-8")
if Prefs["displayAlbumYear"] and album.year() != 0:
title = "%s (%s)" % (title, album.year())
return DirectoryObject(
key = Callback(self.get_album_tracks, uri = album_uri),
title = title,
thumb = self.server.get_art_url(album_uri)
)
示例4: to_mopidy_album
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_album [as 别名]
def to_mopidy_album(spotify_album):
if spotify_album is None:
return
uri = str(Link.from_album(spotify_album))
if not spotify_album.is_loaded():
return Album(uri=uri, name='[loading...]')
return Album(
uri=uri,
name=spotify_album.name(),
artists=[to_mopidy_artist(spotify_album.artist())],
date=spotify_album.year())
示例5: print_search_results
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_album [as 别名]
def print_search_results(self):
print "Artists:"
for a in self.results.artists():
print " ", Link.from_artist(a), a.name()
print "Albums:"
for a in self.results.albums():
print " ", Link.from_album(a), a.name()
print "Tracks:"
for a in self.results.tracks():
print " ", Link.from_track(a, 0), a.name()
print self.results.total_tracks() - len(self.results.tracks()), \
"Tracks not shown"
示例6: browse_album
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_album [as 别名]
def browse_album(self, album, callback):
''' Browse an album, invoking the callback when done
:param album: An album instance to browse.
:param callback: A callback to invoke when the album is loaded.
Should take the browser as a single parameter.
'''
link = Link.from_album(album)
def callback_wrapper(browser, userdata):
self.log("Album browse complete: %s" % link)
callback(browser)
self.log("Browse album: %s" % link)
return AlbumBrowser(album, callback_wrapper)
示例7: create_track_object
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_album [as 别名]
def create_track_object(self, track):
''' Factory for track directory objects '''
album_uri = str(Link.from_album(track.album()))
track_uri = str(Link.from_track(track, 0))
thumbnail_url = self.server.get_art_url(album_uri)
callback = Callback(self.play_track, uri = track_uri, ext = "aiff")
artists = (a.name().decode("utf-8") for a in track.artists())
return TrackObject(
items = [
MediaObject(
parts = [PartObject(key = callback)],
)
],
key = track.name().decode("utf-8"),
rating_key = track.name().decode("utf-8"),
title = track.name().decode("utf-8"),
album = track.album().name().decode("utf-8"),
artist = ", ".join(artists),
index = track.index(),
duration = int(track.duration()),
thumb = thumbnail_url
)
示例8: run
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_album [as 别名]
def run(self):
# wait for container
container_loaded.wait()
container_loaded.clear()
while True:
link_string = self._queue.next_link()
if link_string == '':
break
link = Link.from_string(link_string)
if link.type() == Link.LINK_TRACK:
track = link.as_track()
itrack = iter([track])
elif link.type() == Link.LINK_PLAYLIST \
or link_string == 'spotify:user:'+config_get('username')+':starred':
print 'Loading playlist %s ...' % link_string
playlist = link.as_playlist()
while not playlist.is_loaded():
time.sleep(0.1)
itrack = iter(playlist)
elif link.type() == Link.LINK_ALBUM:
print 'Processing album %s' % str(link)
itrack = [ ]
album = link.as_album()
album_browser = AlbumBrowser(album)
while not album_browser.is_loaded():
time.sleep(0.1)
if self._util.is_compilation(album):
continue
if album.is_available():
print 'Getting tracks for %s' % album.name()
for track in album_browser:
itrack.append(track)
elif link.type() == Link.LINK_ARTIST:
print "Processing artist %s ..." % str(link)
artist = link.as_artist()
artist_browser = ArtistBrowser(artist, 'no_tracks')
while not artist_browser.is_loaded():
time.sleep(0.1)
print "Artist loaded"
print(artist.name())
similar_artists = artist_browser.similar_artists()
for similar_artist in similar_artists:
self._queue.add_artist_link(similar_artist, 'similar')
albums = artist_browser.albums()
processed_albums = [ ]
itrack = [ ]
for album in albums:
if self._util.is_compilation(album):
continue
if album.is_available() and Link.from_album(album) \
not in processed_albums:
processed_albums.append(Link.from_album(album))
print 'Getting tracks for %s' % album.name()
album_browser = AlbumBrowser(album)
while not album_browser.is_loaded():
time.sleep(0.1)
for track in album_browser:
itrack.append(track)
else:
print "Unrecognised link"
os._exit(2)
return
# ripping loop
session = self._ripper.session
for track in itrack:
if self._util.is_known_not_available(Link.from_track(track)):
continue
try:
self._ripper.load_track(track)
while not track.is_loaded():
time.sleep(0.1)
#.........这里部分代码省略.........