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


Python Link.from_playlist方法代码示例

本文整理汇总了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": []}
开发者ID:bne,项目名称:squeal,代码行数:13,代码来源:json.py

示例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")
开发者ID:bne,项目名称:squeal,代码行数:16,代码来源:service.py

示例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)
开发者ID:bok,项目名称:mopidy,代码行数:17,代码来源:translator.py

示例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)
开发者ID:WoLpH,项目名称:mopidy,代码行数:17,代码来源:translator.py

示例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()])
开发者ID:0xadam,项目名称:mopidy,代码行数:19,代码来源:translator.py

示例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()])
开发者ID:cave-scorpion,项目名称:mopidy,代码行数:22,代码来源:translator.py

示例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...")
开发者ID:ryanb93,项目名称:pyApplefy,代码行数:38,代码来源:jukebox.py

示例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)
开发者ID:tylerwilliams,项目名称:echo-spot.com,代码行数:7,代码来源:spotlib.py

示例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
开发者ID:bne,项目名称:squeal,代码行数:6,代码来源:service.py

示例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],
     )
开发者ID:mortenberg80,项目名称:mopidy,代码行数:8,代码来源:libspotify.py


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