Пример #1
0
    def get_album_IDs(self, albumlist_name, page=1):
        '''获取专辑列表中的专辑ID'''
        cache_key = 'aid_' + albumlist_name + str(page)
        if cache_key in self.cached_list:
            self.albumlist = copy.copy(self.cached_list[cache_key])
            return
        if albumlist_name in listing_map_dict:
            p = AlbumListParser()
            print u'正在获取"' + albumlist_name + u'"的专辑列表',
            sys.stdout.flush()
#            for i in range(0, albums_lists[albumlist_name][1], 10):
            i = (page - 1) * 10
            html = self.get_url_html(albums_list_url_template % (listing_map_dict[albumlist_name], i))
            p.feed(html)
            print '.',
            sys.stdout.flush()
#            if callback:
#                callback(int(i / 10) + 1, (albums_lists[albumlist_name][1] / 10))
            print 'done!'
            self.albumlist = p.albumlist
            self.cached_list[cache_key] = copy.copy(p.albumlist)
            return self.check_if_has_more(html)
        else:
            #TODO:raise Exception
            print u'未知专辑列表:"' + str(albumlist_name) + u'",仅支持以下列表: ' + u'、'.join(
            ['"%s"' % key for key in albums_lists])
            return None
Пример #2
0
Файл: core.py Проект: pjq/gmb
 def get_album_IDs(self, albumlist_name, callback=None, updateTreeView=None):
     '''获取专辑列表中的专辑ID'''
     if 'aid_' + albumlist_name in self.cached_list:
         self.albumlist = copy.copy(self.cached_list['aid_' + albumlist_name])
         return
     if albumlist_name in albums_lists:
         p = AlbumListParser()
         print u'正在获取"' + albumlist_name + u'"的专辑列表',
         sys.stdout.flush()
         for i in range(0, albums_lists[albumlist_name][1], 10):
             html = self.get_url_html(albums_list_url_template % (albums_lists[albumlist_name][0], i))
             p.feed(html)
             print '.',
             sys.stdout.flush()
             if callback:
                 callback(int(i / 10) + 1, (albums_lists[albumlist_name][1] / 10))
         print 'done!'
         self.albumlist = p.albumlist
         
         updateTreeView(p.albumlist)
         self.cached_list['aid_' + albumlist_name] = copy.copy(p.albumlist)
     else:
         #TODO:raise Exception
         print u'未知专辑列表:"' + str(albumlist_name) + u'",仅支持以下列表: ' + u'、'.join(
         ['"%s"' % key for key in albums_lists])
Пример #3
0
    def searchalbum(self, key, page=1):
        '''搜索关键字'''
        cache_key = 'said_' + key + str(page)
        if cache_key in self.cached_list:
            self.albumlist = copy.copy(self.cached_list[cache_key])
            return

        key = re.sub((r'\ '), '+', key)
        p = AlbumListParser()
        print u'正在获取"' + key + u'"的专辑搜索结果列表...',
        sys.stdout.flush()
        pnum = (page - 1) * 20
        html = self.get_url_html(albums_search_url_template % (key, pnum))
        p.feed(html)
        sys.stdout.flush()
        print 'done!'
        self.albumlist = p.albumlist
        self.cached_list[cache_key] = copy.copy(p.albumlist)
        return self.check_if_has_more(html)
Пример #4
0
Файл: core.py Проект: pjq/gmb
    def searchalbum(self, key,callback=None):
        '''搜索关键字'''
        if 'said_' + key in self.cached_list:
            self.albumlist = copy.copy(self.cached_list['said_' + key])
            return

        key = re.sub((r'\ '), '+', key)
        p = AlbumListParser()
        print u'正在获取"' + key + u'"的专辑搜索结果列表...',
        sys.stdout.flush()
        pnum = 0
        while isinstance(pnum, int):
            html = self.get_url_html(albums_search_url_template % (key, pnum))
            p.feed(html)
            pnum = self.__get_pnum_by_html(html)
            print '.',
            sys.stdout.flush()
        print 'done!'
        self.albumlist = p.albumlist
        self.cached_list['said_' + key] = copy.copy(p.albumlist)
        
        if callback:
            callback(p.albumlist)