Example #1
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()
Example #2
0
    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
Example #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'])
Example #4
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)
Example #5
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()
Example #6
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'])
Example #7
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)
Example #8
0
 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()
Example #9
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)
Example #10
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)
Example #11
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)
Example #12
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)
Example #13
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()
Example #14
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()
Example #15
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)
Example #16
0
File: MV.py Project: 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()
Example #17
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()
Example #18
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'])
Example #19
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)
Example #20
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)
Example #21
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)
Example #22
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)
Example #23
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)
Example #24
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)
Example #25
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()
Example #26
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)
Example #27
0
        def _show_sub1(sub1_args, error=None):
            nodes, self.sub1_total = sub1_args
            if not nodes or self.sub1_total == 0:
                return
            i = len(self.liststore_sub1)
            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'])
                self.liststore_sub1.append([
                    self.app.theme['anonymous'],
                    Widgets.unescape(node['name']),
                    int(node[_id]),
                    Widgets.unescape(node['info']),
                    _tooltip,
                ])
                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()
Example #28
0
 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 'info' in album and album['info']:
             tooltip = Widgets.set_tooltip(album['name'], album['info'])
         else:
             tooltip = Widgets.escape(album['name'])
         self.liststore_albums.append([
             self.app.theme['anonymous'],
             Widgets.unescape(album['name']),
             int(album['albumid']), 
             Widgets.unescape(album['artist']),
             int(album['artistid']),
             tooltip,
             ])
         Net.update_album_covers(
                 self.liststore_albums, i, 0, album['pic'])
         i += 1
Example #29
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)
Example #30
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)
Example #31
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)
Example #32
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)
Example #33
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)
Example #34
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)
Example #35
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)
Example #36
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)
Example #37
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)
Example #38
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)
Example #39
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)
Example #40
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)
Example #41
0
    def first(self):
        if self.first_show:
            return
        self.first_show = True
        app = self.app
        self.buttonbox = Gtk.Box(spacing=5)
        self.pack_start(self.buttonbox, False, False, 0)
        button_home = Gtk.Button(_('MV'))
        button_home.connect('clicked', self.on_button_home_clicked)
        self.buttonbox.pack_start(button_home, False, False, 0)
        self.label = Gtk.Label('')
        self.buttonbox.pack_start(self.label, False, False, 0)

        # pic, name, artist, album, rid, artistid, albumid, tooltip
        self.liststore_songs = Gtk.ListStore(GdkPixbuf.Pixbuf,
                str, str, str, int, int, int, str)
        self.mv_control_box = Widgets.MVControlBox(self.liststore_songs,
                self.app)
        self.buttonbox.pack_end(self.mv_control_box, False, False, 0)

        self.scrolled_nodes = Gtk.ScrolledWindow()
        self.pack_start(self.scrolled_nodes, True, True, 0)
        # logo, name, nid, info, tooltip
        self.liststore_nodes = Gtk.ListStore(GdkPixbuf.Pixbuf,
                str, int, str, str)
        iconview_nodes = Widgets.IconView(self.liststore_nodes, tooltip=4)
        iconview_nodes.connect('item_activated', 
                self.on_iconview_nodes_item_activated)
        self.scrolled_nodes.add(iconview_nodes)

        self.scrolled_songs = Gtk.ScrolledWindow()
        self.pack_start(self.scrolled_songs, True, True, 0)
        iconview_songs = Widgets.IconView(self.liststore_songs,
                info_pos=2, tooltip=7)
        iconview_songs.connect('item_activated', 
                self.on_iconview_songs_item_activated)
        self.scrolled_songs.add(iconview_songs)

        self.show_all()
        self.buttonbox.hide()
        self.scrolled_songs.hide()

        nid = 3
        nodes_wrap = Net.get_index_nodes(nid)
        if not nodes_wrap:
            return
        nodes = nodes_wrap['child']
        self.liststore_nodes.clear()
        i = 0
        for node in nodes:
            self.liststore_nodes.append([
                self.app.theme['anonymous'],
                Widgets.unescape_html(node['disname']),
                int(node['sourceid']),
                Widgets.unescape_html(node['info']),
                Widgets.set_tooltip(node['disname'], node['info']),
                ])
            Net.update_liststore_image(self.liststore_nodes, i, 0,
                    node['pic'])
            i += 1
Example #42
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)
Example #43
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)
Example #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)
Example #45
0
 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
Example #46
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)
Example #47
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()
Example #48
0
        def _show_sub1(sub1_args, error=None):
            nodes, self.sub1_total = sub1_args
            if error or not nodes or not self.sub1_total:
                return
            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.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()
Example #49
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)
Example #50
0
 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'])
Example #51
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()
Example #52
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)
Example #53
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)
Example #54
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)
Example #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)
Example #56
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)
Example #57
0
 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
     i = len(self.liststore_sub)
     for node in 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'])
         i += 1
Example #58
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)
Example #59
0
    def show_albums(self, reset_status=False):
        keyword = self.search_entry.get_text()
        if len(keyword) == 0:
            return
        if reset_status:
            self.liststore_albums.clear()

        albums, hit, self.albums_total = Net.search_albums(keyword,
                self.albums_page)
        if hit == 0:
            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
Example #60
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)