From 6c2f270d0615e4686eca53dc745021cef3699a41 Mon Sep 17 00:00:00 2001 From: LordKBX Date: Sun, 27 Sep 2020 18:52:07 +0200 Subject: [PATCH] EPUB style modification and fix --- getify.py | 26 +++++++++++++++----------- requirements.txt | 4 +--- ressources/common.css | 13 ++++++++++--- ressources/themes/cream.css | 5 +++-- ressources/themes/dark.css | 3 ++- ressources/themes/dark2.css | 11 +++++++++-- ressources/themes/default.css | 14 +++++++++++--- version.txt | 2 +- wuxiaworld_export_ebook.pyw | 4 ++++ 9 files changed, 56 insertions(+), 26 deletions(-) diff --git a/getify.py b/getify.py index be3f614..05f6519 100644 --- a/getify.py +++ b/getify.py @@ -11,6 +11,7 @@ from bs4 import BeautifulSoup import uuid import html +import traceback def find_between(file): f = open(file, "r", encoding = "utf8") @@ -49,14 +50,15 @@ def clean(file_name_in, file_name_out, start): imgext = tb[len(tb) - 1] imgname = file_name_out + '_im{}'.format(cpt)+'.'+imgext tb = imgname.split('/') - imgname2 = tb[len(tb) - 1] + imgname2 = imgname.replace(tb[len(tb) - 1], 'images/'+tb[len(tb) - 1]) print(img['src']) try: - download(img['src'], imgname) - img['src'] = 'images/'+imgname2 - suplementList.append(imgname2) + + download(img['src'], imgname2) + img['src'] = 'images/'+tb[len(tb) - 1] + suplementList.append('images/'+tb[len(tb) - 1]) except: - {} + traceback.print_exc() cpt += 1 soup = block break @@ -71,8 +73,10 @@ def clean(file_name_in, file_name_out, start): file.write("\n"+'') file.write("\n") file.write("\n") + file.write("\n
") file.write("\n

" + chapter_title + "

") file.write(str(soup).replace('

', '').replace('


', '').replace('
', '')) + file.write("\n
") file.write("\n") file.write("\n") os.remove(file_name_in) @@ -249,7 +253,7 @@ def generate(html_files, novelname, author, chaptername, book, chapter_s, chapte try: os.remove(storage_dir + os.sep + "tmp/cover.png") except: {} - file2 = open("./ressources/common.css", "r") + file2 = open(storage_dir + os.sep + "ressources/common.css", "r") file3 = open(storage_dir + os.sep + "tmp/common.css", "w") ccss = file2.read() file2.close() @@ -259,13 +263,13 @@ def generate(html_files, novelname, author, chaptername, book, chapter_s, chapte epub.write(storage_dir + os.sep + "tmp/common.css", "OEBPS/common.css") for img in suplementList: - epub.write(storage_dir + os.sep + "tmp/"+img, "OEBPS/images/"+img) + epub.write(storage_dir + os.sep + "tmp/"+img, "OEBPS/"+img) try: os.remove(storage_dir + os.sep + "tmp/common.css") except: {} - epub.write("./ressources/fonts/"+font+"/Regular.ttf", "OEBPS/Regular.ttf") - epub.write("./ressources/fonts/"+font+"/Bold.ttf", "OEBPS/Bold.ttf") - epub.write("./ressources/fonts/"+font+"/Bold-Italic.ttf", "OEBPS/Bold-Italic.ttf") - epub.write("./ressources/fonts/"+font+"/Italic.ttf", "OEBPS/Italic.ttf") + epub.write(storage_dir + os.sep + "ressources/fonts/"+font+"/Regular.ttf", "OEBPS/Regular.ttf") + epub.write(storage_dir + os.sep + "ressources/fonts/"+font+"/Bold.ttf", "OEBPS/Bold.ttf") + epub.write(storage_dir + os.sep + "ressources/fonts/"+font+"/Bold-Italic.ttf", "OEBPS/Bold-Italic.ttf") + epub.write(storage_dir + os.sep + "ressources/fonts/"+font+"/Italic.ttf", "OEBPS/Italic.ttf") epub.close() # removes all the temporary files diff --git a/requirements.txt b/requirements.txt index ce5db4e..9a6419f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,4 @@ six>=1.15.0 beautifulsoup4>=4.6.0 lxml>=4.1.1 PyQt5>=5.15.1 -PyQtWebKit>=5.13.1 -pywin32>=228 -Pillow>=7.2.0 \ No newline at end of file +PyQtWebKit>=5.13.1 \ No newline at end of file diff --git a/ressources/common.css b/ressources/common.css index 82951eb..f649d53 100644 --- a/ressources/common.css +++ b/ressources/common.css @@ -21,9 +21,16 @@ img{max-width:100%;height:auto;display:block;margin:0 auto;} .credits{position:fixed;bottom:10px;left:10px;} /*Content Page List only*/ -ol{background:#FFB656;padding-top:15px;padding-bottom:15px;} -ol li{padding:5px;width:calc(100% - 20px);color:#000000;} -ol li a{color:#000000;} +ol{ + background:#57A02C; + padding-top:15px; + padding-bottom:15px; + border:#CCCCCC 1px solid; + border-radius:15px; +} +ol *{ background:#57A02C; color:#000000 !important; } +ol li{padding:5px;width:calc(100% - 20px);} +ol li a{} p{font-weight:100;font-style:normal;} p i{font-weight:100;font-style:italic;} diff --git a/ressources/themes/cream.css b/ressources/themes/cream.css index ca99505..699273e 100644 --- a/ressources/themes/cream.css +++ b/ressources/themes/cream.css @@ -9,6 +9,7 @@ @font-face { font-family: ""; src: url(Bold.ttf); font-weight: bold; } *{font-family:"", sans-serif;background:#FFE0AA;color:#666666;} +body, html{height:100%;background:#FFE0AA;} h1{text-align:center;} h2{text-align:center;} h3{text-align:center;} @@ -21,8 +22,8 @@ img{max-width:100%;height:auto;display:block;margin:0 auto;} .credits{position:fixed;bottom:10px;left:10px;} /*Content Page List only*/ -ol{background:#77A4FF;padding-top:15px;padding-bottom:15px;} -ol *{background:#77A4FF;color:#ffffff;} +ol{background:#D1AF6C;padding-top:15px;padding-bottom:15px; border:#BC852D 1px solid; border-radius:10px; } +ol *{background:#D1AF6C;color:#ffffff !important;} ol li{padding:5px;width:calc(100% - 20px);} ol li a{} diff --git a/ressources/themes/dark.css b/ressources/themes/dark.css index 0255f82..1db760d 100644 --- a/ressources/themes/dark.css +++ b/ressources/themes/dark.css @@ -9,6 +9,7 @@ @font-face { font-family: ""; src: url(Bold.ttf); font-weight: bold; } *{font-family:"", sans-serif;background:#444444;color:#ffffff;} +body, html{height:100%;background:#444444;} h1{text-align:center;} h2{text-align:center;} h3{text-align:center;} @@ -22,7 +23,7 @@ img{max-width:100%;height:auto;display:block;margin:0 auto;} /*Content Page List only*/ ol{background:#7F3300;padding-top:15px;padding-bottom:15px;} -ol *{background:#7F3300;color:#ffffff;} +ol *{background:#7F3300;color:#ffffff !important;} ol li{padding:5px;width:calc(100% - 20px);} ol li a{} diff --git a/ressources/themes/dark2.css b/ressources/themes/dark2.css index c9b9422..e3cde3f 100644 --- a/ressources/themes/dark2.css +++ b/ressources/themes/dark2.css @@ -9,6 +9,7 @@ @font-face { font-family: ""; src: url(Bold.ttf); font-weight: bold; } *{font-family:"", sans-serif;background:#444444;color:#ffffff;} +body, html{background:#444444;height:100%;} h1{text-align:center;} h2{text-align:center;} h3{text-align:center;} @@ -21,8 +22,14 @@ img{max-width:100%;height:auto;display:block;margin:0 auto;} .credits{position:fixed;bottom:10px;left:10px;} /*Content Page List only*/ -ol{background:#57A02C;padding-top:15px;padding-bottom:15px;} -ol *{background:#57A02C;color:#ffffff;} +ol{ + background:#57A02C; + padding-top:15px; + padding-bottom:15px; + border:#CCCCCC 1px solid; + border-radius:15px; +} +ol *{ background:#57A02C; color:#FFFFFF !important; } ol li{padding:5px;width:calc(100% - 20px);} ol li a{} diff --git a/ressources/themes/default.css b/ressources/themes/default.css index 82951eb..438b7d0 100644 --- a/ressources/themes/default.css +++ b/ressources/themes/default.css @@ -9,6 +9,7 @@ @font-face { font-family: ""; src: url(Bold.ttf); font-weight: bold; } *{font-family:"", sans-serif;} +body, html{height:100%;} h1{text-align:center;} h2{text-align:center;} h3{text-align:center;} @@ -21,9 +22,16 @@ img{max-width:100%;height:auto;display:block;margin:0 auto;} .credits{position:fixed;bottom:10px;left:10px;} /*Content Page List only*/ -ol{background:#FFB656;padding-top:15px;padding-bottom:15px;} -ol li{padding:5px;width:calc(100% - 20px);color:#000000;} -ol li a{color:#000000;} +ol{ + background:#57A02C; + padding-top:15px; + padding-bottom:15px; + border:#CCCCCC 1px solid; + border-radius:15px; +} +ol *{ background:#57A02C; color:#000000 !important; } +ol li{padding:5px;width:calc(100% - 20px);} +ol li a{} p{font-weight:100;font-style:normal;} p i{font-weight:100;font-style:italic;} diff --git a/version.txt b/version.txt index 927c5a2..a94a68e 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ 27/09/2020 -10:35:38,26 +18:52:05,66 diff --git a/wuxiaworld_export_ebook.pyw b/wuxiaworld_export_ebook.pyw index 67c7569..179e37f 100644 --- a/wuxiaworld_export_ebook.pyw +++ b/wuxiaworld_export_ebook.pyw @@ -347,6 +347,8 @@ def preview(): if novel == '': infoDialog('Information', "Function availlable only if a novel was selected") return + if os.path.isdir(storage_dir + os.sep + "tmp" + os.sep + "images") is False: + os.mkdir(storage_dir + os.sep + "tmp" + os.sep + "images") app.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor)) book = dialog.bookSelector.currentText() if book not in data_novel['books']: book = 'Book 01' @@ -392,6 +394,8 @@ def generate(): if novel == '': return lockInterface(True) app.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor)) + if os.path.isdir(storage_dir + os.sep + "tmp" + os.sep + "images") is False: + os.mkdir(storage_dir + os.sep + "tmp" + os.sep + "images") status = "Start ebook generation at {}".format( novel, time.asctime() ) updateStatus(status) print(status)