-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmain.py
57 lines (51 loc) · 1.56 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import sys
from loguru import logger
from app import __VERSION__
from app.Modules.epubconv import EPUBConv
from config.config import Config
logger.configure(
handlers=[
{"sink": sys.stdout, "level": Config.STDLEVEL.upper()},
{
"sink": 'storages/logs/app_{time:YYYY-MM-DD}.log',
"level": Config.LOGLEVEL.upper(),
"format": '{time} {level} {message}',
"rotation": '00:00',
"enqueue": True
}
]
)
logger.info(
f'''
______ _ _____
| ____| | | / ____|
| |__ _ __ _ _| |__ | | ___ _ ____ __
| __| | '_ \| | | | '_ \| | / _ \| '_ \ \ / /
| |____| |_) | |_| | |_) | |___| (_) | | | \ V /
|______| .__/ \__,_|_.__/ \_____\___/|_| |_|\_/
| |
|_|
v{__VERSION__}'''
)
logger.debug(Config)
if __name__ == '__main__':
for epub_path in sys.argv[1:]:
epubconv = EPUBConv(epub_path)
epubconv.epub_extract()
content_files = epubconv.epub_file.content_files
css_files = epubconv.epub_file.css_files
opf_file = epubconv.epub_file.opf_file
epubconv.content_convert(content_files)
epubconv.opf_convert(opf_file)
epubconv.file_rename(content_files)
epubconv.writing_format(
opf_path=opf_file,
epub_extract_path=epubconv.epub_extract_path,
css_files=css_files,
content_files=content_files
)
epubconv.epub_compress()
epubconv.clean()
if Config.ENABLE_PAUSE:
os.system('pause')