本文整理汇总了Python中spotify.Link.from_playlist方法的典型用法代码示例。如果您正苦于以下问题:Python Link.from_playlist方法的具体用法?Python Link.from_playlist怎么用?Python Link.from_playlist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spotify.Link
的用法示例。
在下文中一共展示了Link.from_playlist方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: encode
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_playlist [as 别名]
def encode(self):
t = self.original
if t.is_loaded():
return {
u"id": unicode(Link.from_playlist(t)),
u"status": u"",
u"name": unicode(t.name(), "utf-8"),
u"tracks": [simplify(x) for x in t],
}
else:
return {u"id": u"unknown", u"status": u"", u"name": u"Loading...", u"tracks": []}
示例2: getPlaylistByLink
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_playlist [as 别名]
def getPlaylistByLink(self, link):
"""
Pass link as the string representation.
This is a bit evil, there's no other way to do this, and if we
list other people's playlists we'll need to do even more weird stuff.
See
http://getsatisfaction.com/spotify/topics/libspotify_does_not_provide_a_sp_link_as_playlist
"""
for p in self.mgr.ctr:
l = str(Link.from_playlist(p))
if l == link:
return p
log.msg("Cannot find playlist for %s" % link, system="squeal.spot.service.Spotify")
示例3: to_mopidy_playlist
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_playlist [as 别名]
def to_mopidy_playlist(cls, spotify_playlist):
if not spotify_playlist.is_loaded():
return Playlist(name=u'[loading...]')
# FIXME Replace this try-except with a check on the playlist type,
# which is currently not supported by pyspotify, to avoid handling
# playlist folder boundaries like normal playlists.
try:
return Playlist(
uri=str(Link.from_playlist(spotify_playlist)),
name=spotify_playlist.name().decode(ENCODING),
tracks=[cls.to_mopidy_track(t) for t in spotify_playlist],
)
except SpotifyError, e:
logger.warning(u'Failed translating Spotify playlist '
'(probably a playlist folder boundary): %s', e)
示例4: to_mopidy_playlist
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_playlist [as 别名]
def to_mopidy_playlist(cls, spotify_playlist):
if not spotify_playlist.is_loaded():
return Playlist(name=u'[loading...]')
if spotify_playlist.type() != 'playlist':
return
try:
return Playlist(
uri=str(Link.from_playlist(spotify_playlist)),
name=spotify_playlist.name(),
# FIXME if check on link is a hackish workaround for is_local
tracks=[cls.to_mopidy_track(t) for t in spotify_playlist
if str(Link.from_track(t, 0))],
)
except SpotifyError, e:
logger.warning(u'Failed translating Spotify playlist: %s', e)
示例5: to_mopidy_playlist
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_playlist [as 别名]
def to_mopidy_playlist(spotify_playlist):
if spotify_playlist is None or spotify_playlist.type() != 'playlist':
return
uri = str(Link.from_playlist(spotify_playlist))
if not spotify_playlist.is_loaded():
return Playlist(uri=uri, name='[loading...]')
if not spotify_playlist.name():
# Other user's "starred" playlists isn't handled properly by pyspotify
# See https://github.com/mopidy/pyspotify/issues/81
return
return Playlist(
uri=uri,
name=spotify_playlist.name(),
tracks=[
to_mopidy_track(spotify_track)
for spotify_track in spotify_playlist
if not spotify_track.is_local()])
示例6: to_mopidy_playlist
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_playlist [as 别名]
def to_mopidy_playlist(spotify_playlist):
if spotify_playlist is None or spotify_playlist.type() != 'playlist':
return
uri = str(Link.from_playlist(spotify_playlist))
if not spotify_playlist.is_loaded():
return Playlist(uri=uri, name='[loading...]')
name = spotify_playlist.name()
if not name:
# Other user's "starred" playlists isn't handled properly by pyspotify
# See https://github.com/mopidy/pyspotify/issues/81
return
if spotify_playlist.owner().canonical_name() != settings.SPOTIFY_USERNAME:
name += ' by ' + spotify_playlist.owner().canonical_name()
return Playlist(
uri=uri,
name=name,
tracks=[
to_mopidy_track(spotify_track)
for spotify_track in spotify_playlist
if not spotify_track.is_local()])
示例7: do_list
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_playlist [as 别名]
def do_list(self, line):
""" List the playlists, or the contents of a playlist """
if not line:
i = -1
for i, p in enumerate(self.jukebox.ctr):
if p.is_loaded():
if Link.from_playlist(p).type() == Link.LINK_STARRED:
name = "Starred by %s" % p.owner()
else:
name = p.name()
print "%3d %s" % (i, name)
else:
print "%3d %s" % (i, "loading...")
print "%3d Starred tracks" % (i + 1,)
else:
try:
p = int(line)
except ValueError:
print "that's not a number!"
return
if p < 0 or p > len(self.jukebox.ctr):
print "That's out of range!"
return
print "Listing playlist #%d" % p
if p < len(self.jukebox.ctr):
playlist = self.jukebox.ctr[p]
else:
playlist = self.jukebox.starred
for i, t in enumerate(playlist):
if t.is_loaded():
print "%3d %s - %s [%s]" % (
i, t.artists()[0].name(), t.name(),
self.pretty_duration(t.duration()))
else:
print "%3d %s" % (i, "loading...")
示例8: return_playlist
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_playlist [as 别名]
def return_playlist(self):
playlist_urn = Link.from_playlist(self.playlist)
self.output_queue.put(str(playlist_urn))
self.clear_state()
self.change_state(CQSTATE.READY)
示例9: get_playlist
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_playlist [as 别名]
def get_playlist(self, pid):
for playlist in self.mgr.ctr:
if unicode(Link.from_playlist(playlist)) == pid:
return playlist
示例10: _to_mopidy_playlist
# 需要导入模块: from spotify import Link [as 别名]
# 或者: from spotify.Link import from_playlist [as 别名]
def _to_mopidy_playlist(self, spotify_playlist):
return Playlist(
uri=str(Link.from_playlist(spotify_playlist)),
name=spotify_playlist.name().decode(ENCODING),
tracks=[self._to_mopidy_track(t) for t in spotify_playlist],
)