Esempio n. 1
0
def leech(url, session, filename=None, args=None):
    # we have: a page, which could be absolutely any part of a story, or not a story at all
    # check a bunch of things which are completely ff.n specific, to get text from it
    site, url = sites.get(url)
    if not site:
        raise Exception("No site handler found")

    logger.info("Handler: %s (%s)", site, url)

    handler = site(session, args=args)

    with open('leech.json') as config_file:
        config = json.load(config_file)

        login = config.get('logins', {}).get(site.__name__, False)
        if login:
            handler.login(login)

        cover_options = config.get('cover', {})

    story = handler.extract(url)
    if not story:
        raise Exception("Couldn't extract story")

    return ebook.generate_epub(story, filename, cover_options=cover_options)
Esempio n. 2
0
def download(url, site_options, cache, verbose, **other_flags):
    """Downloads a story and saves it on disk as a ebpub ebook."""
    configure_logging(verbose)
    session = create_session(cache)

    site, url = sites.get(url)
    options, login = create_options(site, site_options, other_flags)
    story = open_story(site, url, session, login, options)

    filename = ebook.generate_epub(story)
    logger.info("File created: " + filename)
Esempio n. 3
0
def download(url, site_options, cache, verbose, **other_flags):
    """Downloads a story and saves it on disk as a ebpub ebook."""
    configure_logging(verbose)
    session = create_session(cache)

    site, url = sites.get(url)
    options, login = create_options(site, site_options, other_flags)
    story = open_story(site, url, session, login, options)

    filename = ebook.generate_epub(story, options)
    logger.info("File created: " + filename)