mirror of
https://github.com/kemayo/leech
synced 2026-01-07 16:14:01 +01:00
Actual command-line options
This commit is contained in:
parent
91b7ed3917
commit
136c31ef22
1 changed files with 11 additions and 3 deletions
14
leech.py
14
leech.py
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import argparse
|
||||
import importlib
|
||||
import os
|
||||
|
||||
|
|
@ -20,7 +21,7 @@ html_template = '''<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|||
</html>
|
||||
'''
|
||||
|
||||
def leech(url):
|
||||
def leech(url, filename=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 = _get_site(url)
|
||||
|
|
@ -38,7 +39,9 @@ def leech(url):
|
|||
for i, chapter in enumerate(story['chapters']):
|
||||
html.append((chapter[0], 'chapter%d.html' % (i+1), html_template.format(title=chapter[0], text=chapter[1])))
|
||||
|
||||
epub.make_epub(story['title'] + '.epub', html, metadata)
|
||||
filename = filename or story['title'] + '.epub'
|
||||
|
||||
epub.make_epub(filename, html, metadata)
|
||||
|
||||
_sites = []
|
||||
|
||||
|
|
@ -58,5 +61,10 @@ def _load_sites():
|
|||
|
||||
if __name__ == '__main__':
|
||||
_load_sites()
|
||||
leech('https://www.fanfiction.net/s/4109686/3/Taking-Sights')
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('url', help="url of a story to fetch")
|
||||
parser.add_argument('--filename', help="output filename (the title is used if this isn't provided)")
|
||||
args = parser.parse_args()
|
||||
|
||||
leech(args.url, filename=args.filename)
|
||||
pass
|
||||
|
|
|
|||
Loading…
Reference in a new issue