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


Python NetEase.user_playlist方法代码示例

本文整理汇总了Python中api.NetEase.user_playlist方法的典型用法代码示例。如果您正苦于以下问题:Python NetEase.user_playlist方法的具体用法?Python NetEase.user_playlist怎么用?Python NetEase.user_playlist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在api.NetEase的用法示例。


在下文中一共展示了NetEase.user_playlist方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: User

# 需要导入模块: from api import NetEase [as 别名]
# 或者: from api.NetEase import user_playlist [as 别名]
class User(object):
    def __init__(self):
        self.netease = NetEase()
        self.is_login = False
        self.uid = str()    # ''

    def login(self, username, password):
        data = self.netease.login(username, password)
        code = data['code']
        if code is 200:
            self.uid = data['profile']['userId']
            self.is_login = True
            return True
        else:   # 501
            return False

    def get_favorite_playlist_id(self):
        """
        login required
        success: return playlist id
        fail: return empty string ''
        """
        if self.is_login:
            playlist = self.netease.user_playlist(self.uid)
            for each in playlist:
                if each['specialType'] is 5:    # favorite playlist
                    return each['id']   # the favorite playlist id
            return ''
        return ''

    def get_music_title_and_url(self, pid):
        """
        :param pid: playlist id
        :return re: return list re
        """
        playlist = self.netease.playlist_detail(pid)
        re = list()
        if playlist is not []:
            for music in playlist:
                tmp = dict()
                tmp['title'] = music['name']
                tmp['url'] = music['mp3Url']
                re.append(tmp)
        return re
开发者ID:wangqin4377,项目名称:NetEaseMusic,代码行数:46,代码来源:higherapi.py

示例2: MainWidget

# 需要导入模块: from api import NetEase [as 别名]
# 或者: from api.NetEase import user_playlist [as 别名]

#.........这里部分代码省略.........
            self.ui.status.showMessage(u'当前列表为空', 3000)

    def play_currentplayinglist_music(self, item):
        current_playing = self.ui.info_widget.current_playing_widget
        current_row = current_playing.row(item)
        self.player.stop()
        self.player.setCurrentSource(self.sources[current_row])
        self.player.play()

    def set_search_focus(self):
        self.ui.play_widget.search_edit.setFocus(True)

    def play_pause(self):
        if self.player.state() == Phonon.PlayingState:
            self.player.pause()
        elif self.player.state() == Phonon.PausedState:
            self.player.play()

    def show_login_widget(self):
        d = LoginDialog(self)
        self.connect(d, SIGNAL('loginsuccess'), self.login)
        d.show()

    def login(self, data):
        if data is False:
            uid = '18731323'
        else:
            uid = data['account']['id']
            try:
                self.ui.status.showMessage(u'准备加载头像')
                avatarUrl = data['profile']['avatarUrl']
                self.net_manager.finished.connect(self.avatar_load_finish)
                self.net_manager.finished.disconnect(self.albumimg_load_finish)
                self.load_user_playlist(uid)
                self.net_manager.get(QNetworkRequest(QUrl(avatarUrl)))
                return
            except:
                self.ui.status.showMessage(u'加载头像失败', 2000)
        self.load_user_playlist(uid)

    def load_user_playlist(self, uid):
        playlists = self.net_ease.user_playlist(uid)
        list_widget = self.ui.user_widget.list_widget
        list_widget.clear()
        if playlists is not []:
            for playlist in playlists:
                datamodel = self.model.playlist()
                datamodel = self.model.set_datamodel_from_data(playlist, datamodel)
                item = QListWidgetItem(QIcon('icons/playlist_1.png'), datamodel['name'])
                list_widget.addItem(item)
                data = QVariant((datamodel, ))
                item.setData(Qt.UserRole, data)
        else:
            print 'network error'

    def search(self):
        search_edit = self.ui.play_widget.search_edit
        text= search_edit.text()
        self.ui.status.showMessage(u'正在搜索: ' + text)
        if text != '':
            s = unicode(text.toUtf8(), 'utf8', 'ignore')
            data = self.net_ease.search(s.encode('utf8'))
            songs = list()
            if data['result']['songCount'] != 0:
                songs = data['result']['songs']
                length = len(songs)
开发者ID:alexmao86,项目名称:NetEaseMusic,代码行数:70,代码来源:controllers.py


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