Esempio n. 1
0
    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)
Esempio n. 2
0
        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()
Esempio n. 3
0
 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'])
Esempio n. 4
0
    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)
Esempio n. 5
0
    def append_artist_songs(self, init=False):
        def _append_artist_songs(songs_args, error=None):
            if error or not songs_args or not songs_args[1]:
                logger.error('append_artist_songs(): %s, %s' %
                             (songs_args, error))
                return
            songs, self.artist_songs_total = songs_args
            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']),
                    song['formats'],
                ])
            # 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_tab.get_vscrollbar().set_value(0)
            self.artist_songs_liststore.clear()
            self.artist_songs_page = 0
        Net.async_call(Net.get_artist_songs_by_id,
                       self.curr_artist_id,
                       self.artist_songs_page,
                       callback=_append_artist_songs)
Esempio n. 6
0
    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:
                logger.error('append_arttist_albums(): %s, %s' %
                             (self.artist_albums_taotal, error))
                return
            urls = []
            tree_iters = []
            for album in albums:
                tree_iter = self.artist_albums_liststore.append([
                    Config.ANONYMOUS_PIXBUF,
                    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.async_call(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_tab.get_vscrollbar().set_value(0)
            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, self.curr_artist_id,
                       self.artist_albums_page, callback=_append_artist_albums)
Esempio n. 7
0
 def get_mv_link(self):
     def _update_mv_link(mv_args, error=None):
         mv_link, mv_path = mv_args
         self.show_mv_btn.set_sensitive(mv_link is not False)
     Net.async_call(
             Net.get_song_link, _update_mv_link,
             self.curr_song, self.app.conf, True)
Esempio n. 8
0
        def _on_show_sub2(sub2_args, error=None):
            nodes, self.sub2_total = sub2_args
            if error or not nodes or not self.sub2_total:
                logger.error('nodes: %s, self.sub2_total: %s, error: %s' %
                             (nodes, self.sub2_total, error))
                return
            urls = []
            tree_iters = []
            for node in nodes:
                tree_iter = self.liststore_sub2.append([
                    Config.ANONYMOUS_PIXBUF,
                    Widgets.unescape(node['name']),
                    int(node['sourceid']),
                    Widgets.unescape(node['info']),
                    Widgets.set_tooltip_with_song_tips(node['name'],
                                                       node['tips'])
                ])
                urls.append(node['pic'])
                tree_iters.append(tree_iter)
            Net.async_call(Net.update_liststore_images, self.liststore_sub2, 0,
                           tree_iters, urls)

            self.sub2_page += 1
            if self.sub2_page < self.sub2_total - 1:
                self.show_sub2()
Esempio n. 9
0
        def _on_append_songs(info, error=None):
            if not info or error:
                logger.error('TopCategories.append_songs(): %s, %s' %
                             (info, error))
                return
            songs, self.songs_total = info
            if not songs or self.songs_total == 0 or self.use_album:
                Net.async_call(Net.get_album,
                               self.curr_list_id,
                               callback=_on_get_album)

            for song in songs:
                self.liststore_songs.append([
                    True,
                    Widgets.unescape(song['name']),
                    Widgets.unescape(song['artist']),
                    Widgets.unescape(song['album']),
                    int(song['id']),
                    int(song['artistid']),
                    int(song['albumid']),
                    song['formats'],
                ])
            self.songs_page += 1
            if self.songs_page < self.songs_total - 1:
                self.append_songs()
Esempio n. 10
0
    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)
Esempio n. 11
0
        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([
                    Config.ANONYMOUS_PIXBUF,
                    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()
Esempio n. 12
0
    def update_lrc_background(self, url):
        def _update_background(filepath, error=None):
            if error or not filepath:
                return
            self.app.lrc.update_background(filepath)

        Net.async_call(Net.get_recommend_image, _update_background, url)
Esempio n. 13
0
    def append_artist_info(self):
        def _append_artist_info(info, error=None):
            if info and info['pic'] and len(info['pic']) > 0:
                self.artist_info_pic.set_from_file(info['pic'])
            self.artist_info_name.set(info, 'name')
            self.artist_info_birthday.set(info, 'birthday')
            self.artist_info_birthplace.set(info, 'birthplace')
            self.artist_info_height.set(info, 'tall')
            self.artist_info_weight.set(
                info,
                'weight',
            )
            self.artist_info_country.set(info, 'country')
            self.artist_info_language.set(info, 'language')
            self.artist_info_gender.set(
                info,
                'gender',
            )
            self.artist_info_constellation.set(info, 'constellation')
            if info and 'info' in info:
                self.artist_info_textbuffer.set_text(
                    Widgets.escape(info['info']))
            else:
                self.artist_info_textbuffer.set_text('')

        Net.async_call(Net.get_artist_info, _append_artist_info,
                       self.curr_artist_id)
Esempio n. 14
0
    def append_artist_similar(self, init=False):
        def _append_artist_similar(similar_args, error=None):
            artists, self.artist_similar_total = similar_args
            if self.artist_similar_total == 0:
                return
            i = len(self.artist_similar_liststore)
            for artist in artists:
                _info = ''.join([
                    artist['songnum'],
                    _(' songs'),
                ])
                self.artist_similar_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.artist_similar_liststore, i, 0,
                                       artist['pic'])
                i += 1
            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
        Net.async_call(Net.get_artist_similar, _append_artist_similar,
                       self.curr_artist_id, self.artist_similar_page)
Esempio n. 15
0
    def append_artist_albums(self, init=False):
        def _append_artist_albums(albums_args, error=None):
            albums, self.artist_albums_total = albums_args
            if self.artist_albums_total == 0:
                return
            for i, album in enumerate(albums):
                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']),
                    ])
                Net.update_album_covers(
                        self.artist_albums_liststore, i, 0, album['pic'])
            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
        Net.async_call(
                Net.get_artist_albums, _append_artist_albums,
                self.curr_artist_id, self.artist_albums_page)
Esempio n. 16
0
    def append_artist_songs(self, init=False):
        def _append_artist_songs(songs_args, error=None):
            songs, self.artist_songs_total = songs_args
            if error or 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)
Esempio n. 17
0
    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 self.artist_similar_total == 0:
                return
            for i, artist in enumerate(artists):
                _info = ''.join([artist['songnum'], _(' songs'), ])
                self.artist_similar_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.artist_similar_liststore, i, 0, artist['pic'])
            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
        Net.async_call(
                Net.get_artist_similar, _append_artist_similar,
                self.curr_artist_id, self.artist_similar_page)
Esempio n. 18
0
    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)
Esempio n. 19
0
    def append_artist_info(self):
        def _append_artist_info(info, error=None):
            if error or not info:
                logger.error('appen_artist_info(): %s, %s' % (info, error))
                return
            if info.get('pic', None):
                self.artist_info_pic.set_from_file(info['pic'])
            self.artist_info_name.set(info, 'name')
            self.artist_info_birthday.set(info, 'birthday')
            self.artist_info_birthplace.set(info, 'birthplace')
            self.artist_info_height.set(info, 'tall')
            self.artist_info_weight.set(info, 'weight',)
            self.artist_info_country.set(info, 'country')
            self.artist_info_language.set(info, 'language')
            self.artist_info_gender.set(info, 'gender',)
            self.artist_info_constellation.set(info, 'constellation')
            if info and 'info' in info:
                if html2text_imported:
                    self.artist_info_textbuffer.set_text(
                            html2text.html2text(info['info']))
                else:
                    self.artist_info_textbuffer.set_text(
                            Widgets.escape(info['info']))
            else:
                self.artist_info_textbuffer.set_text('')

        Net.async_call(Net.get_artist_info, self.curr_artist_id,
                       callback=_append_artist_info)
Esempio n. 20
0
    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)
Esempio n. 21
0
    def show_artists(self):
        def _append_artists(artists_args, error=None):
            artists, hit, self.artists_total = artists_args
            if not error and artists and hit:
                urls, tree_iters = [], []
                for artist in artists:
                    tree_iter = self.liststore_artists.append([
                        self.app.theme['anonymous'],
                        Widgets.unescape(artist['ARTIST']),
                        int(artist['ARTISTID']),
                        Widgets.unescape(artist['COUNTRY']),
                    ])
                    tree_iters.append(tree_iter)
                    urls.append(artist['PICPATH'])
                Net.update_artist_logos(self.liststore_artists, 0, tree_iters,
                                        urls)

            self.artists_button.set_label('{0} ({1})'.format(
                _('Artists'), len(self.liststore_artists)))

        # timestamp is used to mark Liststore ID
        if self.artists_page == 0:
            self.liststore_artists.timestamp = time.time()
        Net.async_call(Net.search_artists, _append_artists, self.keyword,
                       self.artists_page)
Esempio n. 22
0
 def update_player_info(self):
     def _update_pic(info, error=None):
         if not info or error:
             logger.error('update_player_info(): %s, %s' % (info, 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 = Config.ANONYMOUS_IMG
         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>{1}</small> <span size="x-small">{2}</span>'.format(
             name, artist, album)
     self.label.set_label(label)
     self.app.window.set_title(name)
     self.artist_pic.set_from_pixbuf(Config.ANONYMOUS_PIXBUF)
     Net.async_call(Net.get_artist_info, song['artistid'], song['artist'],
                    callback=_update_pic)
Esempio n. 23
0
    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)
Esempio n. 24
0
File: MV.py Progetto: zihua/kwplayer
 def _on_append_songs(info, error=None):
     if error or not info or not info[0] or not info[1]:
         logger.error('append_songs():  %s, %s' % (info, error))
         return
     songs, self.songs_total = info
     urls = []
     tree_iters = []
     for song in songs:
         tree_iter = self.liststore_songs.append([
             Config.ANONYMOUS_PIXBUF,
             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.async_call(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()
Esempio n. 25
0
 def _append_artist_similar(similar_args, error=None):
     artists, self.artist_similar_total = similar_args
     if error or not self.artist_similar_total:
         logger.error('append_artist_similar(): %s, %s' %
                      (self.artist_similar_total, error))
         return
     urls = []
     tree_iters = []
     for artist in artists:
         _info = ''.join([
             artist['songnum'],
             _(' songs'),
         ])
         tree_iter = self.artist_similar_liststore.append([
             Config.ANONYMOUS_PIXBUF,
             Widgets.unescape(artist['name']),
             int(artist['id']),
             _info,
             Widgets.set_tooltip(artist['name'], _info),
         ])
         urls.append(artist['pic'])
         tree_iters.append(tree_iter)
     Net.async_call(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()
Esempio n. 26
0
    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'])
Esempio n. 27
0
    def append_artist_albums(self, init=False):
        def _append_artist_albums(albums_args, error=None):
            albums, self.artist_albums_total = albums_args
            if self.artist_albums_total == 0:
                return
            i = len(self.artist_albums_liststore)
            for album in albums:
                if len(album['info']) == 0:
                    tooltip = Widgets.tooltip(album['name'])
                else:
                    tooltip = '<b>{0}</b>\n{1}'.format(
                            Widgets.tooltip(album['name']),
                            Widgets.tooltip(album['info']))
                self.artist_albums_liststore.append([
                    self.app.theme['anonymous'], album['name'],
                    int(album['albumid']), album['artist'],
                    int(album['artistid']), tooltip, ])
                Net.update_album_covers(self.artist_albums_liststore, i,
                        0, album['pic'])
                i += 1
            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
        Net.async_call(Net.get_artist_albums, _append_artist_albums,
                self.curr_artist_id, self.artist_albums_page)
Esempio n. 28
0
    def get_mv_link(self):
        def _update_mv_link(mv_args, error=None):
            mv_link, mv_path = mv_args
            self.use_mtv_btn.set_sensitive(mv_link is not False)

        Net.async_call(Net.get_song_link, _update_mv_link, self.curr_song,
                       self.app.conf, True)
Esempio n. 29
0
    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'],
                    Widgets.unescape(mv['name']),
                    Widgets.unescape(mv['artist']),
                    '',
                    int(mv['musicid']),
                    int(mv['artistid']),
                    0,
                    Widgets.set_tooltip(mv['name'], mv['artist']),
                ])
                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)
Esempio n. 30
0
    def show_sub1(self, init=False):
        def _show_sub1(sub1_args, error=None):
            nodes, self.sub1_total = sub1_args
            if nodes is None or self.sub1_total == 0:
                return
            i = len(self.liststore_sub1)
            for node in nodes:
                _id = 'id' if self.use_sub2 else 'sourceid'
                self.liststore_sub1.append([self.app.theme['anonymous'],
                    node['name'], int(node[_id]), node['info'], ])
                Net.update_liststore_image(self.liststore_sub1, i, 0, 
                        node['pic'])
                i += 1
            self.sub1_page += 1
            if self.sub1_page < self.sub1_total - 1:
                self.show_sub1()

        if init:
            self.scrolled_main.hide()
            self.buttonbox.show_all()
            self.button_sub1.hide()
            self.button_sub2.hide()
            self.control_box.hide()
            self.scrolled_sub1.get_vadjustment().set_value(0)
            self.scrolled_sub1.show_all()
            self.sub1_page = 0
            self.liststore_sub1.clear()
        Net.async_call(Net.get_nodes, _show_sub1,
                self.curr_sub1_id, self.sub1_page)
Esempio n. 31
0
    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)
Esempio n. 32
0
    def show_sub2(self, init=False):
        def _show_sub2(sub2_args, error=None):
            nodes, self.sub2_total = sub2_args
            if nodes is None or self.sub2_total == 0:
                return
            i = len(self.liststore_sub2)
            for node in nodes:
                self.liststore_sub2.append([self.app.theme['anonymous'],
                    Widgets.unescape_html(node['name']),
                    int(node['sourceid']),
                    Widgets.unescape_html(node['info']), ])
                Net.update_liststore_image(self.liststore_sub2, i, 0, 
                        node['pic'])
                i += 1
            self.sub2_page += 1
            if self.sub2_page < self.sub2_total - 1:
                self.show_sub2()

        if init:
            self.scrolled_sub1.hide()
            self.button_sub1.show_all()
            self.scrolled_sub2.get_vadjustment().set_value(0)
            self.scrolled_sub2.show_all()
            self.sub2_page = 0
            self.liststore_sub2.clear()
        Net.async_call(Net.get_nodes, _show_sub2,
                self.curr_sub2_id, self.sub2_page)
Esempio n. 33
0
    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
            for i, mv in enumerate(mvs):
                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']),
                    ])
                Net.update_mv_image(
                        self.artist_mv_liststore, i, 0, mv['pic'])
            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)
Esempio n. 34
0
    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'],
                    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']),
                    ])
                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)
Esempio n. 35
0
    def append_artist_songs(self, init=False):
        def _append_artist_songs(songs_args, error=None):
            if error or not songs_args or not songs_args[1]:
                logger.error('append_artist_songs(): %s, %s' %
                             (self.artist_songs_total, error))
                return
            songs, self.artist_songs_total = songs_args
            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']),
                    song['formats'],
                ]) 
            # 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_tab.get_vscrollbar().set_value(0)
            self.artist_songs_liststore.clear()
            self.artist_songs_page = 0
        Net.async_call(Net.get_artist_songs_by_id, self.curr_artist_id,
                       self.artist_songs_page, callback=_append_artist_songs)
Esempio n. 36
0
    def show_songs(self, reset_status=False):
        def _append_songs(songs_args, error=None):
            songs, hit, self.songs_total = songs_args
            if not songs or hit == 0:
                if reset_status:
                    self.songs_button.set_label('{0} (0)'.format(_('Songs')))
                return
            self.songs_button.set_label('{0} ({1})'.format(_('Songs'), hit))
            for song in songs:
                self.liststore_songs.append([
                    False,
                    Widgets.unescape(song['SONGNAME']),
                    Widgets.unescape(song['ARTIST']),
                    Widgets.unescape(song['ALBUM']),
                    int(song['MUSICRID'][6:]),
                    int(song['ARTISTID']),
                    int(song['ALBUMID']),
                    ])

        keyword = self.search_entry.get_text()
        self.app.playlist.advise_new_playlist_name(keyword)
        if not keyword:
            return
        if reset_status:
            self.liststore_songs.clear()
        Net.async_call(
                Net.search_songs, _append_songs, keyword, self.songs_page)
Esempio n. 37
0
 def _append_artist_mv(mv_args, error=None):
     mvs, self.artist_mv_total = mv_args
     if error or self.artist_mv_total == 0:
         logger.error('append_artist_mv(): %s, %s' %
                      (self.artist_mv_total, error))
         return
     urls = []
     tree_iters = []
     for mv in mvs:
         tree_iter = self.artist_mv_liststore.append([
             Config.ANONYMOUS_PIXBUF,
             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.async_call(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()
Esempio n. 38
0
    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'],
                    Widgets.unescape(artist['ARTIST']),
                    int(artist['ARTISTID']), 
                    Widgets.unescape(artist['COUNTRY']),
                    ])
                Net.update_artist_logo(
                        self.liststore_artists, i, 0, artist['PICPATH'])
                i += 1

        keyword = self.search_entry.get_text()
        if not keyword:
            return
        if reset_status:
            self.liststore_artists.clear()
        Net.async_call(
                Net.search_artists, _append_artists,
                keyword,self.artists_page)
Esempio n. 39
0
 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'])
Esempio n. 40
0
    def show_artists(self):
        def _append_artists(artists_args, error=None):
            artists, hit, self.artists_total = artists_args
            if not error and artists and hit:
                urls, tree_iters = [], []
                for artist in artists:
                    tree_iter = self.liststore_artists.append([
                        Config.ANONYMOUS_PIXBUF,
                        Widgets.unescape(artist['ARTIST']),
                        int(artist['ARTISTID']),
                        Widgets.unescape(artist['COUNTRY']),
                    ])
                    tree_iters.append(tree_iter)
                    urls.append(artist['PICPATH'])
                Net.async_call(Net.update_artist_logos, self.liststore_artists,
                               0, tree_iters, urls)
            else:
                logger.error('show_artists(): %s, %s' %
                             (self.artists_total, error))

            self.artists_button.set_label('{0} ({1})'.format(_('Artists'),
                                          len(self.liststore_artists)))

        # timestamp is used to mark Liststore ID
        if self.artists_page == 0:
            self.liststore_artists.timestamp = time.time()
        Net.async_call(Net.search_artists, self.keyword, self.artists_page,
                       callback=_append_artists)
Esempio n. 41
0
    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)
Esempio n. 42
0
    def show_albums(self):
        def _append_albums(albums_args, error=None):
            albums, hit, self.albums_total = albums_args
            if not error and albums and hit:
                urls,tree_iters = [], []
                for album in albums:
                    tooltip = Widgets.escape(album.get('info',
                                             album['name']))
                    tree_iter = self.liststore_albums.append([
                        Config.ANONYMOUS_PIXBUF,
                        Widgets.unescape(album['name']),
                        int(album['albumid']),
                        Widgets.unescape(album['artist']),
                        int(album['artistid']),
                        tooltip,
                    ])
                    tree_iters.append(tree_iter)
                    urls.append(album['pic'])
                Net.async_call(Net.update_album_covers, self.liststore_albums,
                               0, tree_iters, urls)
            else:
                logger.error('show_albums: %s, %s' % (self.albums_total, error))

            self.albums_button.set_label('{0} ({1})'.format(_('Albums'),
                                         len(self.liststore_albums)))

        if self.albums_page == 0:
            self.liststore_albums.timestamp = time.time()
        Net.async_call(Net.search_albums, self.keyword, self.albums_page,
                       callback=_append_albums)
Esempio n. 43
0
    def show_albums(self):
        def _append_albums(albums_args, error=None):
            albums, hit, self.albums_total = albums_args
            if not error and albums and hit:
                urls, tree_iters = [], []
                for album in albums:
                    tooltip = Widgets.escape(album.get('info', album['name']))
                    tree_iter = self.liststore_albums.append([
                        self.app.theme['anonymous'],
                        Widgets.unescape(album['name']),
                        int(album['albumid']),
                        Widgets.unescape(album['artist']),
                        int(album['artistid']),
                        tooltip,
                    ])
                    tree_iters.append(tree_iter)
                    urls.append(album['pic'])
                Net.update_album_covers(self.liststore_albums, 0, tree_iters,
                                        urls)

            self.albums_button.set_label('{0} ({1})'.format(
                _('Albums'), len(self.liststore_albums)))

        if self.albums_page == 0:
            self.liststore_albums.timestamp = time.time()
        Net.async_call(Net.search_albums, _append_albums, self.keyword,
                       self.albums_page)
Esempio n. 44
0
    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)
Esempio n. 45
0
    def show_songs(self, reset_status=False):
        def _append_songs(songs_args, error=None):
            songs, hit, self.songs_total = songs_args
            if not songs or hit == 0:
                if reset_status:
                    self.songs_button.set_label(
                            '{0} (0)'.format(_('Songs')))
                return
            self.songs_button.set_label(
                    '{0} ({1})'.format(_('Songs'), hit))
            for song in songs:
                self.liststore_songs.append([False,
                    song['SONGNAME'],
                    song['ARTIST'], song['ALBUM'],
                    int(song['MUSICRID'][6:]),
                    int(song['ARTISTID']),
                    int(song['ALBUMID']), ])

        keyword = self.search_entry.get_text()
        self.app.playlist.advise_new_playlist_name(keyword)
        if len(keyword) == 0:
            return
        if reset_status:
            self.liststore_songs.clear()
        Net.async_call(Net.search_songs, _append_songs,
                keyword, self.songs_page)
Esempio n. 46
0
    def show_artists(self, reset_status=False):
        def _append_artists(artists_args, error=None):
            artists, hit, self.artists_total = artists_args
            if (error or not hit) and reset_status:
                self.artists_button.set_label('{0} (0)'.format(_('Artists')))
                return
            self.artists_button.set_label(
                    '{0} ({1})'.format(_('Artists'), hit))
            urls = []
            tree_iters = []
            for artist in artists:
                tree_iter = self.liststore_artists.append([
                    self.app.theme['anonymous'],
                    Widgets.unescape(artist['ARTIST']),
                    int(artist['ARTISTID']), 
                    Widgets.unescape(artist['COUNTRY']),
                    ])
                tree_iters.append(tree_iter)
                urls.append(artist['PICPATH'])
            Net.update_artist_logos(
                    self.liststore_artists, 0, tree_iters, urls)

        keyword = self.search_entry.get_text()
        if not keyword:
            return
        if reset_status:
            self.liststore_artists.clear()
        if reset_status or not hasattr(self.liststore_artists, 'timestamp'):
            self.liststore_artists.timestamp = time.time()
        Net.async_call(
                Net.search_artists, _append_artists,
                keyword,self.artists_page)
Esempio n. 47
0
    def show_albums(self, reset_status=False):
        def _append_albums(albums_args, error=None):
            albums, hit, self.albums_total = albums_args
            if hit == 0:
                if reset_status:
                    self.albums_button.set_label(
                            '{0} (0)'.format(_('Albums')))
                return
            self.albums_button.set_label(
                    '{0} ({1})'.format(_('Albums'), hit))
            i = len(self.liststore_albums)
            for album in albums:
                if len(album['info']) == 0:
                    tooltip = Widgets.tooltip(album['name'])
                else:
                    tooltip = '<b>{0}</b>\n{1}'.format(
                            Widgets.tooltip(album['name']),
                            Widgets.tooltip(album['info']))
                self.liststore_albums.append([self.app.theme['anonymous'],
                    album['name'],
                    int(album['albumid']), 
                    album['artist'],
                    int(album['artistid']),
                    tooltip, ])
                Net.update_album_covers(self.liststore_albums,
                        i, 0, album['pic'])
                i += 1

        keyword = self.search_entry.get_text()
        if len(keyword) == 0:
            return
        if reset_status:
            self.liststore_albums.clear()
        Net.async_call(Net.search_albums, _append_albums,
                keyword, self.albums_page)
Esempio n. 48
0
    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)
Esempio n. 49
0
 def _append_artist_mv(mv_args, error=None):
     mvs, self.artist_mv_total = mv_args
     if error or self.artist_mv_total == 0:
         logger.error('append_artist_mv(): %s, %s' %
                      (self.artist_mv_total, error))
         return
     urls = []
     tree_iters = []
     for mv in mvs:
         tree_iter = self.artist_mv_liststore.append([
             Config.ANONYMOUS_PIXBUF,
             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.async_call(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()
Esempio n. 50
0
    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)
Esempio n. 51
0
    def append_artist_info(self):
        def _append_artist_info(info, error=None):
            if error or not info:
                logger.error('appen_artist_info(): %s, %s' % (info, error))
                return
            if info.get('pic', None):
                self.artist_info_pic.set_from_file(info['pic'])
            self.artist_info_name.set(info, 'name')
            self.artist_info_birthday.set(info, 'birthday')
            self.artist_info_birthplace.set(info, 'birthplace')
            self.artist_info_height.set(info, 'tall')
            self.artist_info_weight.set(
                info,
                'weight',
            )
            self.artist_info_country.set(info, 'country')
            self.artist_info_language.set(info, 'language')
            self.artist_info_gender.set(
                info,
                'gender',
            )
            self.artist_info_constellation.set(info, 'constellation')
            if info and 'info' in info:
                if html2text_imported:
                    self.artist_info_textbuffer.set_text(
                        html2text.html2text(info['info']))
                else:
                    self.artist_info_textbuffer.set_text(
                        Widgets.escape(info['info']))
            else:
                self.artist_info_textbuffer.set_text('')

        Net.async_call(Net.get_artist_info,
                       self.curr_artist_id,
                       callback=_append_artist_info)
Esempio n. 52
0
    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)
Esempio n. 53
0
        def _on_show_sub2(sub2_args, error=None):
            nodes, self.sub2_total = sub2_args
            if error or not nodes or not self.sub2_total:
                logger.error('nodes: %s, self.sub2_total: %s, error: %s' %
                        (nodes, self.sub2_total, error))
                return
            urls = []
            tree_iters = []
            for node in nodes:
                tree_iter = self.liststore_sub2.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'])
                ])
                urls.append(node['pic'])
                tree_iters.append(tree_iter)
            Net.async_call(Net.update_liststore_images, self.liststore_sub2, 0,
                           tree_iters, urls)

            self.sub2_page += 1
            if self.sub2_page < self.sub2_total - 1:
                self.show_sub2()
Esempio n. 54
0
    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)
Esempio n. 55
0
    def show_sub2(self, init=False):
        def _show_sub2(sub2_args, error=None):
            nodes, self.sub2_total = sub2_args
            if not nodes or self.sub2_total == 0:
                return
            i = len(self.liststore_sub2)
            for node in nodes:
                self.liststore_sub2.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_sub2, i, 0,
                                           node['pic'])
                i += 1

            self.sub2_page += 1
            if self.sub2_page < self.sub2_total - 1:
                self.show_sub2()

        if init:
            self.scrolled_sub1.hide()
            self.button_sub1.show_all()
            self.scrolled_sub2.get_vadjustment().set_value(0)
            self.scrolled_sub2.show_all()
            self.sub2_page = 0
            self.liststore_sub2.clear()
        Net.async_call(Net.get_nodes, _show_sub2, self.curr_sub2_id,
                       self.sub2_page)
Esempio n. 56
0
    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)
Esempio n. 57
0
    def show_songs(self, init=False):
        if init:
            self.app.playlist.advise_new_playlist_name(self.label.get_text())
            self.liststore_songs.clear()
            self.songs_page = 0
            self.scrolled_sub.hide()
            self.button_sub.show_all()
            self.control_box.show_all()
            self.scrolled_songs.get_vscrollbar().set_value(0)
            self.scrolled_songs.show_all()

        def _on_get_themes_songs(info, error):
            if not info or not info[0] or not info[1] or error:
                logger.error('show_songs(): %s, %s' % (info, error))
                return
            songs, self.songs_total = info
            for song in songs:
                self.liststore_songs.append([
                    True,
                    Widgets.unescape(song['name']),
                    Widgets.unescape(song['artist']),
                    Widgets.unescape(song['album']),
                    int(song['id']),
                    int(song['artistid']),
                    int(song['albumid']),
                    song['formats'],
                ])

        Net.async_call(Net.get_themes_songs,
                       self.curr_list_id,
                       self.songs_page,
                       callback=_on_get_themes_songs)
Esempio n. 58
0
    def append_artist_albums(self, init=False):
        def _append_artist_albums(albums_args, error=None):
            albums, self.artist_albums_total = albums_args
            if self.artist_albums_total == 0:
                return
            i = len(self.artist_albums_liststore)
            for album in albums:
                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']),
                ])
                Net.update_album_covers(self.artist_albums_liststore, i, 0,
                                        album['pic'])
                i += 1
            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
        Net.async_call(Net.get_artist_albums, _append_artist_albums,
                       self.curr_artist_id, self.artist_albums_page)