本文整理汇总了Python中spotify.Link.from_artist方法的典型用法代码示例。如果您正苦于以下问题:Python Link.from_artist方法的具体用法?Python Link.from_artist怎么用?Python Link.from_artist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spotify.Link
的用法示例。
在下文中一共展示了Link.from_artist方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: to_mopidy_artist
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_artist [as 别名]
def to_mopidy_artist(cls, spotify_artist):
if not spotify_artist.is_loaded():
return Artist(name=u'[loading...]')
return Artist(
uri=str(Link.from_artist(spotify_artist)),
name=spotify_artist.name()
)
示例2: add_artist_link
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_artist [as 别名]
def add_artist_link(self, artist, source):
"""
Add an artist link to the queue.
"""
link = str(Link.from_artist(artist))
if not self._items:
self._items = [ ]
with open('queue.json', 'r') as fp:
self._items = json.load(fp)
found = False
for item in self._items:
if item['link'] == link:
found = True
break
if not found:
while not artist.is_loaded():
time.sleep(0.1)
print 'Adding %s' % artist.name()
self._items.append({
'name': artist.name(),
'link': link,
'source': source,
})
with open('queue.json', 'w') as fp:
json.dump(self._items, fp, indent=2)
return True
示例3: do_search
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_artist [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)
示例4: action_search
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_artist [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, _)
示例5: to_mopidy_artist
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_artist [as 别名]
def to_mopidy_artist(spotify_artist):
if spotify_artist is None:
return
uri = str(Link.from_artist(spotify_artist))
if not spotify_artist.is_loaded():
return Artist(uri=uri, name='[loading...]')
return Artist(uri=uri, name=spotify_artist.name())
示例6: add_artist_to_directory
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_artist [as 别名]
def add_artist_to_directory(self, artist, directory):
artist_uri = str(Link.from_artist(artist))
directory.add(
DirectoryObject(
key = Callback(self.get_artist_albums, uri = artist_uri),
title = artist.name().decode("utf-8"),
thumb = R("placeholder-artist.png")
)
)
示例7: print_search_results
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_artist [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"
示例8: browse_artist
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_artist [as 别名]
def browse_artist(self, artist, callback):
''' Browse an artist, invoking the callback when done
:param artist: An artist 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_artist(artist)
def callback_wrapper(browser, userdata):
self.log("Artist browse complete: %s" % Link.from_artist(artist))
callback(browser)
self.log("Browse artist: %s" % link)
browser = ArtistBrowser(artist, "no_tracks", callback_wrapper)
return browser
示例9: callback_wrapper
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_artist [as 别名]
def callback_wrapper(browser, userdata):
self.log("Artist browse complete: %s" % Link.from_artist(artist))
callback(browser)
示例10: _to_mopidy_artist
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_artist [as 别名]
def _to_mopidy_artist(self, spotify_artist):
return Artist(
uri=str(Link.from_artist(spotify_artist)),
name=spotify_artist.name().decode(ENCODING),
)