本文整理汇总了Python中kuwo.Net类的典型用法代码示例。如果您正苦于以下问题:Python Net类的具体用法?Python Net怎么用?Python Net使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Net类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: append_artist_albums
def append_artist_albums(self, init=False):
def _append_artist_albums(albums_args, error=None):
albums, self.artist_albums_total = albums_args
if error or self.artist_albums_total == 0:
return
urls = []
tree_iters = []
for album in albums:
tree_iter = self.artist_albums_liststore.append([
self.app.theme['anonymous'],
Widgets.unescape(album['name']),
int(album['albumid']),
Widgets.unescape(album['artist']),
int(album['artistid']),
Widgets.set_tooltip(album['name'], album['info']),
])
urls.append(album['pic'])
tree_iters.append(tree_iter)
Net.update_album_covers(
self.artist_albums_liststore, 0, tree_iters, urls)
self.artist_albums_page += 1
if self.artist_albums_page < self.artist_albums_total - 1:
self.append_artist_albums()
if init:
self.artist_albums_liststore.clear()
self.artist_albums_page = 0
if init or not hasattr(self.artist_albums, 'timestamp'):
self.artist_albums_liststore.timestamp = time.time()
Net.async_call(
Net.get_artist_albums, _append_artist_albums,
self.curr_artist_id, self.artist_albums_page)
示例2: append_artists
def append_artists(self, init=False):
if init:
self.artists_liststore.clear()
self.artists_page = 0
self.artists_win.get_vadjustment().set_value(0)
selection = self.cate_treeview.get_selection()
result = selection.get_selected()
if result is None or len(result) != 2:
return
model, _iter = result
pref_index = self.pref_combo.get_active()
catid = model[_iter][1]
prefix = self.pref_liststore[pref_index][1]
# TODO: use async_call()
artists, self.artists_total = Net.get_artists(catid,
self.artists_page, prefix)
if self.artists_total == 0:
return
i = len(self.artists_liststore)
for artist in artists:
self.artists_liststore.append([self.app.theme['anonymous'],
artist['name'], int(artist['id']),
artist['music_num'] + _(' songs'), ])
Net.update_artist_logo(self.artists_liststore, i, 0,
artist['pic'])
i += 1
示例3: update_player_info
def update_player_info(self):
def _update_pic(info, error=None):
if info is None or error:
return
self.artist_pic.set_tooltip_text(
Widgets.short_tooltip(info['info'], length=500))
if info['pic']:
pix = GdkPixbuf.Pixbuf.new_from_file_at_size(
info['pic'], 100, 100)
self.artist_pic.set_from_pixbuf(pix)
song = self.curr_song
name = Widgets.short_tooltip(song['name'], 45)
if len(song['artist']) > 0:
artist = Widgets.short_tooltip(song['artist'], 20)
else:
artist = _('Unknown')
if len(song['album']) > 0:
album = Widgets.short_tooltip(song['album'], 30)
else:
album = _('Unknown')
label = '<b>{0}</b> <i><small>by {1} from {2}</small></i>'.format(
name, artist, album)
self.label.set_label(label)
self.artist_pic.set_from_pixbuf(self.app.theme['anonymous'])
Net.async_call(Net.get_artist_info, _update_pic,
song['artistid'], song['artist'])
示例4: show_artists
def show_artists(self, reset_status=False):
def _append_artists(artists_args, error=None):
artists, hit, self.artists_total = artists_args
if hit == 0:
if reset_status:
self.artists_button.set_label(
'{0} (0)'.format(_('Artists')))
return
self.artists_button.set_label(
'{0} ({1})'.format(_('Artists'), hit))
i = len(self.liststore_artists)
for artist in artists:
self.liststore_artists.append([self.app.theme['anonymous'],
artist['ARTIST'],
int(artist['ARTISTID']),
artist['COUNTRY'], ])
Net.update_artist_logo(self.liststore_artists, i, 0,
artist['PICPATH'])
i += 1
keyword = self.search_entry.get_text()
if len(keyword) == 0:
return
if reset_status:
self.liststore_artists.clear()
Net.async_call(Net.search_artists, _append_artists,
keyword, self.artists_page)
示例5: _on_show_sub1
def _on_show_sub1(info, error=None):
if not info or not info[0] or not info[1] or error:
logger.error('show_sub1(): %s, %s' % (info, error))
return
nodes, self.sub1_total = info
urls = []
tree_iters = []
for node in nodes:
id_ = 'id' if self.use_sub2 else 'sourceid'
if 'tips' in node and len(node['tips']) > 5:
tooltip = Widgets.set_tooltip_with_song_tips(node['name'],
node['tips'])
else:
tooltip = Widgets.set_tooltip(node['name'], node['info'])
tree_iter = self.liststore_sub1.append([
self.app.theme['anonymous'],
Widgets.unescape(node['name']),
int(node[id_]),
Widgets.unescape(node['info']),
tooltip,
])
urls.append(node['pic'])
tree_iters.append(tree_iter)
Net.async_call(Net.update_liststore_images, self.liststore_sub1, 0,
tree_iters, urls)
self.sub1_page += 1
if self.sub1_page < self.sub1_total - 1:
self.show_sub1()
示例6: append_songs
def append_songs(self, init=False):
def _append_songs(songs_args, error=None):
songs, self.songs_total = songs_args
if error or not self.songs_total:
return
urls = []
tree_iters = []
for song in songs:
tree_iter = self.liststore_songs.append([
self.app.theme['anonymous'],
Widgets.unescape(song['name']),
Widgets.unescape(song['artist']),
Widgets.unescape(song['album']),
int(song['id']),
int(song['artistid']),
int(song['albumid']),
Widgets.set_tooltip(song['name'], song['artist']),
])
tree_iters.append(tree_iter)
urls.append(song['mvpic'])
Net.update_mv_images(
self.liststore_songs, 0, tree_iters, urls)
self.songs_page += 1
if self.songs_page < self.songs_total - 1:
self.append_songs()
if init:
self.app.playlist.advise_new_playlist_name(self.label.get_text())
self.songs_page = 0
self.liststore_songs.clear()
if init or not hasattr(self.liststore_songs, 'timestamp'):
self.liststore_songs.timestamp = time.time()
Net.async_call(
Net.get_mv_songs, _append_songs,
self.curr_node_id, self.songs_page)
示例7: append_songs
def append_songs(self, init=False):
def _append_songs(songs_args, error=None):
songs, self.songs_total = songs_args
if self.songs_total == 0:
return
i = len(self.liststore_songs)
for song in songs:
self.liststore_songs.append([
self.app.theme['anonymous'],
song['name'],
song['artist'],
song['album'],
int(song['id']),
int(song['artistid']),
int(song['albumid']),
Widgets.set_tooltip(song['name'], song['artist']),
])
Net.update_mv_image(self.liststore_songs, i, 0,
song['mvpic'])
i += 1
self.songs_page += 1
if self.songs_page < self.songs_total - 1:
self.append_songs()
if init:
self.app.playlist.advise_new_playlist_name(
self.label.get_text())
self.songs_page = 0
self.liststore_songs.clear()
Net.async_call(Net.get_mv_songs, _append_songs,
self.curr_node_id, self.songs_page)
示例8: append_artists
def append_artists(self, init=False):
def on_append_artists(info, error=None):
artists, self.artists_total = info
if error or not self.artists_total or not artists:
return
for i, artist in enumerate(artists):
_info = ' '.join([artist['music_num'], _(' songs'), ])
self.artists_liststore.append([
self.app.theme['anonymous'],
Widgets.unescape(artist['name']),
int(artist['id']),
_info,
Widgets.set_tooltip(artist['name'], _info),
])
Net.update_artist_logo(
self.artists_liststore, i, 0, artist['pic'])
if init:
self.artists_liststore.clear()
self.artists_page = 0
self.artists_win.get_vadjustment().set_value(0)
selection = self.cate_treeview.get_selection()
result = selection.get_selected()
if result is None or len(result) != 2:
return
model, _iter = result
pref_index = self.pref_combo.get_active()
catid = model[_iter][1]
prefix = self.pref_liststore[pref_index][1]
Net.async_call(
Net.get_artists, on_append_artists, catid,
self.artists_page, prefix)
示例9: append_artist_songs
def append_artist_songs(self, init=False):
def _append_artist_songs(songs_args, error=None):
songs, self.artist_songs_total = songs_args
if self.artist_songs_total == 0:
return
for song in songs:
self.artist_songs_liststore.append([
True,
Widgets.unescape(song['name']),
Widgets.unescape(song['artist']),
Widgets.unescape(song['album']),
int(song['musicrid']),
int(song['artistid']),
int(song['albumid']),
])
# automatically load more songs
self.artist_songs_page += 1
if self.artist_songs_page < self.artist_songs_total - 1:
self.append_artist_songs()
if init:
self.artist_songs_liststore.clear()
self.artist_songs_page = 0
Net.async_call(
Net.get_artist_songs_by_id, _append_artist_songs,
self.curr_artist_id, self.artist_songs_page)
示例10: append_artist_mv
def append_artist_mv(self, init=False):
def _append_artist_mv(mv_args, error=None):
mvs, self.artist_mv_total = mv_args
if self.artist_mv_total == 0:
return
i = len(self.artist_mv_liststore)
for mv in mvs:
self.artist_mv_liststore.append([
self.app.theme['anonymous'],
mv['name'],
mv['artist'],
'',
int(mv['musicid']),
int(mv['artistid']),
0, ])
Net.update_mv_image(self.artist_mv_liststore, i, 0,
mv['pic'])
i += 1
self.artist_mv_page += 1
if self.artist_mv_page < self.artist_mv_total - 1:
self.append_artist_mv()
if init:
self.artist_mv_liststore.clear()
self.artist_mv_page = 0
Net.async_call(Net.get_artist_mv, _append_artist_mv,
self.curr_artist_id, self.artist_mv_page)
示例11: show_sub
def show_sub(self, init=False):
if init:
self.scrolled_main.hide()
self.scrolled_songs.hide()
self.buttonbox.show_all()
self.button_sub.hide()
self.control_box.hide()
self.scrolled_sub.get_vadjustment().set_value(0)
self.scrolled_sub.show_all()
self.nodes_page = 0
self.liststore_sub.clear()
nodes, self.nodes_total = Net.get_nodes(
self.curr_sub_id, self.nodes_page)
if not nodes:
return
for i, node in enumerate(nodes):
self.liststore_sub.append([
self.app.theme['anonymous'],
Widgets.unescape(node['name']),
int(node['sourceid']),
Widgets.unescape(node['info']),
Widgets.set_tooltip_with_song_tips(
node['name'], node['tips']),
])
Net.update_liststore_image(
self.liststore_sub, i, 0, node['pic'])
示例12: get_lrc
def get_lrc(self):
def _update_lrc(lrc_text, error=None):
if error:
logger.error('get_lrc(): %s', error)
self.app.lrc.set_lrc(lrc_text)
Net.async_call(Net.get_lrc, self.curr_song, callback=_update_lrc)
示例13: append_artist_similar
def append_artist_similar(self, init=False):
self.first()
def _append_artist_similar(similar_args, error=None):
artists, self.artist_similar_total = similar_args
if error or not self.artist_similar_total:
return
urls = []
tree_iters = []
for artist in artists:
_info = ''.join([artist['songnum'], _(' songs'), ])
tree_iter = self.artist_similar_liststore.append([
self.app.theme['anonymous'],
Widgets.unescape(artist['name']),
int(artist['id']),
_info,
Widgets.set_tooltip(artist['name'], _info),
])
urls.append(artist['pic'])
tree_iters.append(tree_iter)
Net.update_artist_logos(
self.artist_similar_liststore, 0, tree_iters, urls)
self.artist_similar_page += 1
if self.artist_similar_page < self.artist_similar_total - 1:
self.append_artist_similar()
if init:
self.artist_similar_liststore.clear()
self.artist_similar_page = 0
if init or not hasattr(self.artist_similar_liststore, 'timestamp'):
self.artist_similar_liststore.timestamp = time.time()
Net.async_call(
Net.get_artist_similar, _append_artist_similar,
self.curr_artist_id, self.artist_similar_page)
示例14: append_artist_mv
def append_artist_mv(self, init=False):
def _append_artist_mv(mv_args, error=None):
mvs, self.artist_mv_total = mv_args
if error or self.artist_mv_total == 0:
return
urls = []
tree_iters = []
for mv in mvs:
tree_iter = self.artist_mv_liststore.append([
self.app.theme['anonymous'],
Widgets.unescape(mv['name']),
Widgets.unescape(mv['artist']),
'',
int(mv['musicid']),
int(mv['artistid']),
0,
Widgets.set_tooltip(mv['name'], mv['artist']),
])
tree_iters.append(tree_iter)
urls.append(mv['pic'])
Net.update_mv_images(
self.artist_mv_liststore, 0, tree_iters, urls)
self.artist_mv_page += 1
if self.artist_mv_page < self.artist_mv_total - 1:
self.append_artist_mv()
if init:
self.artist_mv_liststore.clear()
self.artist_mv_page = 0
if init or not hasattr(self.artist_mv_liststore, 'timestamp'):
self.artist_mv_liststore.timestamp = time.time()
Net.async_call(
Net.get_artist_mv, _append_artist_mv,
self.curr_artist_id, self.artist_mv_page)
示例15: update_player_info
def update_player_info(self):
def _update_pic(info, error=None):
if not info or error:
return
self.artist_pic.set_tooltip_text(
Widgets.short_tooltip(info['info'], length=500))
if info['pic']:
self.meta_artUrl = info['pic']
pix = GdkPixbuf.Pixbuf.new_from_file_at_size(
info['pic'], 100, 100)
self.artist_pic.set_from_pixbuf(pix)
else:
self.meta_artUrl = self.app.theme_path['anonymous']
self.notify.refresh()
self.dbus.update_meta()
song = self.curr_song
name = Widgets.short_tooltip(song['name'], 45)
if song['artist']:
artist = Widgets.short_tooltip(song['artist'], 20)
else:
artist = _('Unknown')
if song['album']:
album = Widgets.short_tooltip(song['album'], 30)
else:
album = _('Unknown')
label = '<b>{0}</b> <small>by {1} from {2}</small>'.format(
name, artist, album)
self.label.set_label(label)
self.app.window.set_title(name)
self.artist_pic.set_from_pixbuf(self.app.theme['anonymous'])
Net.async_call(
Net.get_artist_info, _update_pic,
song['artistid'], song['artist'])