コード例 #1
0
def do_download(service_name, comic_id, account):
    service = account.services[service_name]
    issue = service.get_issue(comic_id)
    active_downloads[comic_id] = {
            'title': '%s #%s' % (issue.title, issue.num),
            'message': '',
            'progress': 0
            }

    def on_cbz_progress(value=None, message=None, error=None):
        if value is not None:
            active_downloads[comic_id]['progress'] = value
        if message is not None:
            active_downloads[comic_id]['message'] = message
        if error is not None:
            active_downloads[comic_id]['message'] = "ERROR: " + error

    try:
        library = CbzLibrary(g.account.library_path)
        builder = CbzBuilder()
        builder.set_watermark(service_name, service.username)
        builder.set_temp_folder(cache_dir)
        builder.set_progress_subscriber(on_cbz_progress)
        app.logger.debug('Downloading %s [%s] to: %s' % (issue.title, comic_id, account.library_path))
        builder.save(issue, in_library=library)
    except Exception as e:
        app.logger.error('Error downloading comic: %s' % e)
    finally:
        active_downloads.pop(comic_id)
コード例 #2
0
def sync(service_name, series_id):
    if service_name is None:
        services = [v for k, v in g.account.services.iteritems()]
    else:
        services = [g.account.services[service_name]]

    library = CbzLibrary(g.account.library_path)
    builder = CbzBuilder()
    builder.set_temp_folder(cache_dir)
    # TODO: progress subscriber
    for service in services:
        builder.set_watermark(service.service_name, service.username)

        # Get all issues for the given series, or all issues ever if `None`.
        issues = service.get_all_issues(series_id)
        library.sync_issues(builder, issues)