Compare commits

...

3 Commits

Author SHA1 Message Date
d7f38882f2 Fixed png/jpg thumbnail generation 2023-05-17 22:17:20 +02:00
f1aba58732 Fixed ampersand 2023-05-17 21:47:14 +02:00
11d1418c09 Updated gitignore 2023-05-17 21:01:38 +02:00
4 changed files with 41 additions and 23 deletions

4
.gitignore vendored
View File

@ -2,4 +2,6 @@
__pycache__/ __pycache__/
.env .env
deploy.sh deploy.sh
env env
thumbnails
*.db

36
main.py
View File

@ -125,6 +125,7 @@ def generate():
files_without_comicinfo = 0 files_without_comicinfo = 0
errorcount = 0 errorcount = 0
skippedcount = 0 skippedcount = 0
errormsg = ""
for root, dirs, files in os.walk(os.path.abspath(config.CONTENT_BASE_DIR)): for root, dirs, files in os.walk(os.path.abspath(config.CONTENT_BASE_DIR)):
for file in files: for file in files:
f = os.path.join(root, file) f = os.path.join(root, file)
@ -139,8 +140,9 @@ def generate():
if force == 'True': if force == 'True':
ext = [i for i, x in enumerate(filelist) if re.search("(?i)\.jpg|png|jpeg$", x)] ext = [i for i, x in enumerate(filelist) if re.search("(?i)\.jpg|png|jpeg$", x)]
cover = s.open(filelist[ext[0]]).read() cover = s.open(filelist[ext[0]]).read()
image = Image.open(BytesIO(cover)) image = Image.open(BytesIO(cover))
rgb_im = image.convert("RGB")
image.thumbnail(config.MAXSIZE,Image.ANTIALIAS) image.thumbnail(config.MAXSIZE,Image.ANTIALIAS)
image.save(config.THUMBNAIL_DIR + "/" + str(CVDB) + ".jpg") image.save(config.THUMBNAIL_DIR + "/" + str(CVDB) + ".jpg")
@ -149,18 +151,23 @@ def generate():
#c.write(cover) #c.write(cover)
#c.close() #c.close()
generated = generated + 1 generated = generated + 1
elif Path(config.THUMBNAIL_DIR + "/" + str(CVDB) + ".jpg").exists() == False: if Path(config.THUMBNAIL_DIR + "/" + str(CVDB) + ".jpg").exists() == False:
ext = [i for i, x in enumerate(filelist) if re.search("(?i)\.jpg|png|jpeg$", x)] config._print("generating for " + str(CVDB))
config._print(filelist) try:
config._print(ext) ext = [i for i, x in enumerate(filelist) if re.search("(?i)\.jpg|png|jpeg$", x)]
config._print(filelist[ext[0]]) #config._print(filelist)
cover = s.open(filelist[ext[0]]).read() #config._print(ext)
#xyz = [i for i, x in enumerate(filelist) if re.match('*\.py$',x)] #config._print(filelist[ext[0]])
#config._print(xyz) cover = s.open(filelist[ext[0]]).read()
image = Image.open(BytesIO(cover)) #xyz = [i for i, x in enumerate(filelist) if re.match('*\.py$',x)]
image.thumbnail(config.MAXSIZE,Image.ANTIALIAS) #config._print(xyz)
image.save(config.THUMBNAIL_DIR + "/" + str(CVDB) + ".jpg") image = Image.open(BytesIO(cover))
generated = generated + 1 image.thumbnail(config.MAXSIZE,Image.ANTIALIAS)
image.save(config.THUMBNAIL_DIR + "/" + str(CVDB) + ".jpg")
generated = generated + 1
except Exception as e:
errormsg = str(e)
print(e)
else: else:
skippedcount = skippedcount + 1 skippedcount = skippedcount + 1
else: else:
@ -169,7 +176,8 @@ def generate():
errorcount = errorcount + 1 errorcount = errorcount + 1
config._print("Error (/generate): " + str(e)) config._print("Error (/generate): " + str(e))
config._print(f) config._print(f)
return "Forced generation: " + str(force) + "<br>Comics: " + str(comiccount) + "<br>Generated: " + str(generated) + "<br>CBZ files without ComicInfo.xml: " + str(files_without_comicinfo) + "<br>Errors: " + str(errorcount) + "<br>Skipped: " + str(skippedcount) errormsg = str(e)
return "Forced generation: " + str(force) + "<br>Comics: " + str(comiccount) + "<br>Generated: " + str(generated) + "<br>CBZ files without ComicInfo.xml: " + str(files_without_comicinfo) + "<br>Errors: " + str(errorcount) + "<br>Skipped: " + str(skippedcount) + "<br>" + errormsg
@app.route('/import') @app.route('/import')

View File

@ -53,6 +53,7 @@ class Entry(object):
#print(">>entry.py") #print(">>entry.py")
#print(kwargs) #print(kwargs)
print(kwargs["title"])
#print(kwargs["links"][0].get("rpath")) #print(kwargs["links"][0].get("rpath"))
#print("--end entry.py") #print("--end entry.py")
try: try:
@ -60,8 +61,8 @@ class Entry(object):
f=self.links[0].get("rpath")+"/"+self.title+".cbz" f=self.links[0].get("rpath")+"/"+self.title+".cbz"
if os.path.exists(f): if os.path.exists(f):
s = zipfile.ZipFile(f) s = zipfile.ZipFile(f)
#self.size = extras.get_size(f, 'mb') self.size = extras.get_size(f, 'mb')
data=BeautifulSoup(s.open('ComicInfo.xml').read(), "xml") data=BeautifulSoup(s.open('ComicInfo.xml').read(), features="html.parser")
#self.cover=s.open('P00001.jpg').read() #self.cover=s.open('P00001.jpg').read()
if data.select('Writer') != []: if data.select('Writer') != []:
@ -69,10 +70,17 @@ class Entry(object):
else: else:
config._print("No Writer found: " + str(data.select('Writer'))) config._print("No Writer found: " + str(data.select('Writer')))
#self.cover = "/image/" + extras.get_cvdb(data.select('Notes')) + ".jpg" self.cover = "/image/" + extras.get_cvdb(data.select('Notes')) + ".jpg"
#if data.select('Title') != []:
# self.title = data.select('Title')[0]
# print(data.select('Title')[0])
title = data.select('Title')[0].text.replace("&","&amp;")
kwargs["title"] = title
print(title)
if data.select('Summary') != []: if data.select('Summary') != []:
self.summary = data.select('Summary')[0].text #print(data.select('Summary')[0].text)
self.summary = data.select('Summary')[0]
else: else:
config._print("No Summary found: " + str(data.select('Summary'))) config._print("No Summary found: " + str(data.select('Summary')))
@ -84,12 +92,12 @@ class Entry(object):
if data.select('Series')[0].text in kwargs["links"][0].get("rpath"): if data.select('Series')[0].text in kwargs["links"][0].get("rpath"):
releasedate=data.select('Year')[0].text+"-"+data.select('Month')[0].text.zfill(2)+"-"+data.select('Day')[0].text.zfill(2) releasedate=data.select('Year')[0].text+"-"+data.select('Month')[0].text.zfill(2)+"-"+data.select('Day')[0].text.zfill(2)
try: try:
self.title = "#"+data.select('Number')[0].text.zfill(2) + ": " + data.select('Title')[0].text + " (" + releasedate + ") [" + str(self.size) + "MB]" self.title = "#"+data.select('Number')[0].text.zfill(2) + ": " + title + " (" + releasedate + ") [" + str(self.size) + "MB]"
except: except:
self.title = "#"+data.select('Number')[0].text.zfill(2) + " (" + releasedate + ") [" + str(self.size) + "MB]" self.title = "#"+data.select('Number')[0].text.zfill(2) + " (" + releasedate + ") [" + str(self.size) + "MB]"
#print(self.title) #print(self.title)
else: else:
self.title = kwargs["title"] self.title = title
else: else:
self.title = kwargs["title"] self.title = kwargs["title"]

View File

@ -27,7 +27,7 @@
<entry> <entry>
<title>{{ entry.title }}</title> <title>{{ entry.title }}</title>
<id>{{ entry.id }}</id> <id>{{ entry.id }}</id>
m!-- <summary type="text">{{ entry.summary }}</summary> --> <summary type="text">{{ entry.summary }}</summary>
{% for author in entry.authors %} {% for author in entry.authors %}
<author> <author>
<name>{{ author }}</name> <name>{{ author }}</name>