本文整理汇总了Python中api.NetEase.search方法的典型用法代码示例。如果您正苦于以下问题:Python NetEase.search方法的具体用法?Python NetEase.search怎么用?Python NetEase.search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api.NetEase
的用法示例。
在下文中一共展示了NetEase.search方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search_music
# 需要导入模块: from api import NetEase [as 别名]
# 或者: from api.NetEase import search [as 别名]
def search_music(q, limit):
netease = NetEase()
r = netease.search(q, limit=limit)
if r['code'] != 200:
return jsonify({
"error" : True
})
else:
ids = []
for song in r['result']['songs']:
ids.append(song['id'])
musics = netease.songs_detail(ids)
outputs = []
for music in musics:
outputs.append({
"error" : False,
"name" : music['name'],
"cover" : music['album']['blurPicUrl'],
"album_name": music['album']['name'],
"author": music['artists'][0]['name'],
"url" : music['mp3Url']
})
outputs = {
"error" : False,
"type" : "music",
"musics" : outputs
}
return jsonify(outputs)
示例2: __init__
# 需要导入模块: from api import NetEase [as 别名]
# 或者: from api.NetEase import search [as 别名]
def __init__(self, song_name):
self.mp3_date = None
netease = NetEase()
data = netease.search(song_name, stype=1, offset=0, total='true', limit=60)
# print data
song_ids = []
if 'songs' in data['result']:
if 'mp3Url' in data['result']['songs']:
songs = data['result']['songs']
else:
for i in range(0, len(data['result']['songs']) ):
song_ids.append( data['result']['songs'][i]['id'] )
songs = netease.songs_detail(song_ids)
self.mp3_data = netease.dig_info(songs, 'songs') #歌曲信息,album, artist, song_name, mp3_url
示例3: NetEase
# 需要导入模块: from api import NetEase [as 别名]
# 或者: from api.NetEase import search [as 别名]
#coding=utf-8
#import player
from api import NetEase
import mp3play
import time
netease = NetEase()
data = netease.search(u'南山南', stype=1, offset=0, total='true', limit=60)
print data
song_ids = []
if 'songs' in data['result']:
if 'mp3Url' in data['result']['songs']:
songs = data['result']['songs']
print songs
else:
for i in range(0, len(data['result']['songs']) ):
song_ids.append( data['result']['songs'][i]['id'] )
songs = netease.songs_detail(song_ids)
mp3_url_data = netease.dig_info(songs, 'songs')
print mp3_url_data
for mp3_url in mp3_url_data:
print mp3_url['album_name']
print mp3_url['artist']
print mp3_url['song_name']
print mp3_url['mp3_url']
print '---------------------------'
#{'mp3_url': u'http://m2.music.126.net/GkFXC6qt6rEU2q9KYU-6yQ==/1373290025677371.mp3', 'song_id': 41462137, 'album_name': u'\u6587\u6b66\u8d1d\u94a2\u7434\u6539\u7f16\u4f5c\u54c1\u96c6\uff082015\u5e74\u5168\u96c6\uff09', 'song_name': u'\u5357\u5c71\u5357-\u6587\u6b66\u8d1d\u94a2\u7434\u7248', 'artist': u'\u6587\u6b66\u8d1d'}
示例4: MainWidget
# 需要导入模块: from api import NetEase [as 别名]
# 或者: from api.NetEase import search [as 别名]
class MainWidget(QWidget):
def __init__(self, parent=None):
super(MainWidget, self).__init__(parent)
# set app name before mediaObject was created to avoid phonon problem
QCoreApplication.setApplicationName("NetEaseMusic-ThirdParty")
self.ui = UiMainWidget()
self.ui.setup_ui(self)
self.signal_mapper = QSignalMapper(self)
self.player = Phonon.createPlayer(Phonon.MusicCategory)
self.net_manager = QNetworkAccessManager()
self.searchShortcut = QShortcut(QKeySequence("Ctrl+F"), self)
self.sources = []
self.net_ease = NetEase()
self.model = DataModel()
self.set_self_prop()
self.set_signal_binding()
self.init_table_widget()
def init_table_widget(self):
self.ui.info_widget.music_table_widget.close()
self.ui.info_widget.music_search_widget.close()
self.ui.info_widget.current_playing_widget.close()
def set_self_prop(self):
self.setWindowTitle('NetEaseMusic For Linux')
self.setObjectName('main_widget')
self.resize(960, 580)
self.setWindowIcon(QIcon('icons/format.ico'))
def paintEvent(self, QPaintEvent):
"""
self is derived from QWidget, Stylesheets don't work unless \
paintEvent is reimplemented.
at the same time, if self is derived from QFrame, this isn't needed.
"""
option = QStyleOption()
option.init(self)
painter = QPainter(self)
style = self.style()
style.drawPrimitive(QStyle.PE_Widget, option, painter, self)
def set_signal_binding(self):
self.searchShortcut.activated.connect(self.set_search_focus)
self.ui.info_widget.music_table_widget.itemDoubleClicked.connect(
self.play_userplaylist_music)
self.ui.info_widget.music_search_widget.itemDoubleClicked.connect(
self.play_search_music)
self.ui.info_widget.current_playing_widget.itemDoubleClicked.connect(
self.play_currentplayinglist_music)
self.ui.user_widget.list_widget.itemDoubleClicked.connect(
self.play_userlist)
self.ui.user_widget.list_widget.itemClicked.connect(
self.set_tablewidget_userplaylist)
self.player.setTickInterval(1000)
self.player.tick.connect(self.tick)
self.player.stateChanged.connect(self.state_changed)
self.player.currentSourceChanged.connect(self.source_changed)
self.player.aboutToFinish.connect(self.about_to_finish)
self.ui.play_widget.play_pause_btn.clicked.connect(self.play_pause)
self.ui.play_widget.last_music_btn.clicked.connect(
self.last_music)
self.ui.play_widget.next_music_btn.clicked.connect(
self.next_music)
self.ui.play_widget.seek_slider.setMediaObject(self.player)
self.ui.play_widget.login_btn.clicked.connect(self.show_login_widget)
self.ui.play_widget.search_btn.clicked.connect(self.search)
self.ui.play_widget.search_edit.returnPressed.connect(self.search)
self.ui.play_widget.show_current_list.clicked.connect(self.set_tablewidget_currentplayinglist)
self.ui.play_widget.help_btn.clicked.connect(self.show_help_info)
self.net_manager.finished.connect(self.albumimg_load_finish)
def show_help_info(self):
print 'show help info'
with open('data/help.html') as f:
text = f.read()
text = text.decode('utf8')
message = QMessageBox(self)
message.setText(text)
message.setTextFormat(Qt.RichText)
message.show()
pass
def play_userlist(self, item):
userplaylist_widget = self.ui.user_widget.list_widget
data = item.data(Qt.UserRole)
playlist = data.toPyObject()[0]
pid = playlist['id']
res = self.net_ease.playlist_detail(pid)
# table_widget.clear()
if res is not []:
current_playing = self.ui.info_widget.current_playing_widget
# 清空当前播放列表
self.sources = []
current_playing.setRowCount(0)
# 把歌曲全部加入列表
for music in res:
#.........这里部分代码省略.........