Exemple #1
0
def download_illustrations(user,
                           data_list,
                           save_path='.',
                           add_user_folder=False,
                           add_rank=False,
                           skip_manga=False):
    """Download illustratons

    Args:
        user: PixivApi()
        data_list: json
        save_path: str, download path of the illustrations
        add_user_folder: bool, whether put the illustration into user folder
        add_rank: bool, add illustration rank at the beginning of filename
    """
    illustrations = PixivIllustModel.from_data(data_list, user)
    if skip_manga:
        manga_number = sum([is_manga(i) for i in illustrations])
        if manga_number:
            print('skip', manga_number, 'manga')
            illustrations = list(
                filter(lambda x: not is_manga(x), illustrations))
    download_queue, count = check_files(illustrations, save_path,
                                        add_user_folder, add_rank)[0:2]
    if count > 0:
        print(_('Start download, total illustrations '), count)
        global _finished_download, _Global_Download
        _finished_download = 0
        _Global_Download = 0
        start_and_wait_download_threading(download_queue, count)
        print()
    else:
        print(_('There is no new illustration need to download'))
Exemple #2
0
def artist_folder_scanner(user, user_id_list, save_path, final_list, fast):
    while not user_id_list.empty():
        user_info = user_id_list.get()
        user_id = user_info['id']
        folder = user_info['folder']
        try:
            per_page = 9999
            if fast:
                per_page = _fast_mode_size
                data_list = user.get_user_illustrations(user_id, per_page=per_page)
                if len(data_list) > 0:
                    file_path = os.path.join(save_path, folder, data_list[-1]['image_urls']['large'].split('/')[-1])
                    while not os.path.exists(file_path) and per_page <= len(data_list):
                        per_page += _fast_mode_size
                        data_list = user.get_user_illustrations(user_id, per_page=per_page)
                        file_path = os.path.join(save_path, folder, data_list[-1]['image_urls']['large'].split('/')[-1])
            else:
                data_list = user.get_user_illustrations(user_id, per_page=per_page)
            illustrations = PixivIllustModel.from_data(data_list, user)
            count, checked_list = check_files(illustrations, save_path, add_user_folder=True, add_rank=False)[1:3]
            if len(sys.argv) < 2 or count:
                try:
                    print(_('Artists %s [%s]') % (folder, count))
                except UnicodeError:
                    print(_('Artists %s ?? [%s]') % (user_id, count))
            with _PROGRESS_LOCK:
                for index in checked_list:
                    final_list.append(data_list[index])
        except Exception as e:
            print(e)
        user_id_list.task_done()
Exemple #3
0
def download_illustrations(data_list, save_path='.', add_user_folder=False, add_rank=False):
    """Download illustratons

    Args:
        data_list: json
        save_path: str, download path of the illustrations
        add_user_folder: bool, whether put the illustration into user folder
        add_rank: bool, add illustration rank at the beginning of filename
    """
    illustrations = PixivIllustModel.from_data(data_list)
    check_files(illustrations, save_path, add_user_folder, add_rank)

    if count_illustrations(illustrations) > 0:
        print(_('Start download, total illustrations'), count_illustrations(illustrations))

        download_queue = queue.Queue()
        for illustration in illustrations:
            download_queue.put(illustration)

        global _queue_size, _finished_download, _Global_Download
        _queue_size = count_illustrations(illustrations)
        _finished_download = 0
        _Global_Download = 0
        start_and_wait_download_threading(download_queue, save_path, add_user_folder, add_rank)
        print()
    else:
        print(_('There is no new illustration need to download'))
Exemple #4
0
def download_illusts(data_list, save_path='.', add_user_folder=False, add_rank=False):
    illusts = PixivIllustModel.from_data(data_list)

    if len(illusts) > 0:
        print('Start download, total illusts', len(illusts))

        if add_user_folder:
            save_path = get_file_path(illusts[0], save_path)

        download_queue = queue.Queue()
        for illust in illusts:
            download_queue.put(illust)

        global _queue_size, _finished_download
        _queue_size = len(illusts)
        _finished_download = 0

        start_and_wait_download_threadings(download_queue, save_path, add_rank)

    else:
        print('There is no new illust need to download')
Exemple #5
0
def download_illustrations(user, data_list, save_path='.', add_user_folder=False, add_rank=False):
    """Download illustratons

    Args:
        user: PixivApi()
        data_list: json
        save_path: str, download path of the illustrations
        add_user_folder: bool, whether put the illustration into user folder
        add_rank: bool, add illustration rank at the beginning of filename
    """
    illustrations = PixivIllustModel.from_data(data_list, user)
    download_queue, count = check_files(illustrations, save_path, add_user_folder, add_rank)[0:2]
    if count > 0:
        print(_('Start download, total illustrations '), count)
        global _finished_download, _Global_Download
        _finished_download = 0
        _Global_Download = 0
        start_and_wait_download_threading(download_queue, count)
        print()
    else:
        print(_('There is no new illustration need to download'))
Exemple #6
0
def download_illustrations(data_list, save_path='.', add_user_folder=False, add_rank=False, refresh=False):
    illustrations = PixivIllustModel.from_data(data_list)

    if not refresh:
        check_files(illustrations, save_path, add_rank)

    if len(illustrations) > 0:
        print(_('Start download, total illustrations '), len(illustrations))

        if add_user_folder:
            save_path = get_file_path(illustrations[0], save_path)

        download_queue = queue.Queue()
        for illustration in illustrations:
            download_queue.put(illustration)

        global _queue_size, _finished_download, _Global_Download
        _queue_size = len(illustrations)
        _finished_download = 0
        _Global_Download = 0
        start_and_wait_download_trending(download_queue, save_path, add_rank, refresh)
        print()
    else:
        print(_('There is no new illustration need to download'))