-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
37 lines (26 loc) · 1016 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import argparse
import logging
from epubgen.Facade import Facade, Identity
def enable_http_debug():
from http.client import HTTPConnection
HTTPConnection.debuglevel = 1
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
def parse_args():
parser = argparse.ArgumentParser(description='Epub Downloader for Safari')
parser.add_argument('--cookie', help='the cookie file that used to send request')
parser.add_argument('bookids', nargs="+", help='the list of bookid that to be downloaded')
return vars(parser.parse_args())
def main():
logging.basicConfig(level=logging.INFO)
args = parse_args()
identity = Identity(args["cookie"])
facade = Facade(identity)
for book_id in args['bookids']:
facade.retrieve_epub(book_id)
facade.create_epub(book_id)
if __name__ == "__main__":
main()