From 8c69a958def4c14a930e568692c98e30e2d6ed26 Mon Sep 17 00:00:00 2001 From: FrederikBaerentsen Date: Wed, 17 May 2023 20:29:52 +0200 Subject: [PATCH] Trying to fix issues with summary and Ampersand in title --- main.py | 10 ++--- opds/entry.py | 66 +++++++++++++++--------------- opds/templates/catalog.opds.jinja2 | 2 +- 3 files changed, 40 insertions(+), 38 deletions(-) diff --git a/main.py b/main.py index 9d27d72..a759997 100644 --- a/main.py +++ b/main.py @@ -245,7 +245,7 @@ def import2sql(): @app.route("/content/") @auth.login_required def send_content(path): - print('content') + #print('content') return send_from_directory(config.CONTENT_BASE_DIR, path) @app.route("/image/") @@ -267,10 +267,10 @@ def catalog(path=""): c = fromdir(request.root_url, request.url, config.CONTENT_BASE_DIR, path) #print("c: ") #pprint(vars(c)) - for x in c.entries: - for y in x.links: - pprint(y.href) - print("------") + #for x in c.entries: + # for y in x.links: + # pprint(y.href) + #print("------") elapsed = timeit.default_timer() - start_time print("-----------------------------------------------------------------------------------------------------------------------") print("RENDERED IN: " + str(round(elapsed,2))+"s") diff --git a/opds/entry.py b/opds/entry.py index 8bc4b4f..186d157 100644 --- a/opds/entry.py +++ b/opds/entry.py @@ -55,45 +55,47 @@ class Entry(object): #print(kwargs) #print(kwargs["links"][0].get("rpath")) #print("--end entry.py") + try: + if kwargs["links"][0].get("type") == 'application/x-cbz': + f=self.links[0].get("rpath")+"/"+self.title+".cbz" + if os.path.exists(f): + s = zipfile.ZipFile(f) + #self.size = extras.get_size(f, 'mb') + data=BeautifulSoup(s.open('ComicInfo.xml').read(), "xml") + #self.cover=s.open('P00001.jpg').read() - if kwargs["links"][0].get("type") == 'application/x-cbz': - f=self.links[0].get("rpath")+"/"+self.title+".cbz" - if os.path.exists(f): - s = zipfile.ZipFile(f) - self.size = extras.get_size(f, 'mb') - data=BeautifulSoup(s.open('ComicInfo.xml').read(), "xml") - #self.cover=s.open('P00001.jpg').read() + if data.select('Writer') != []: + self.authors = data.select('Writer')[0].text.split(",") + else: + config._print("No Writer found: " + str(data.select('Writer'))) + + #self.cover = "/image/" + extras.get_cvdb(data.select('Notes')) + ".jpg" - if data.select('Writer') != []: - self.authors = data.select('Writer')[0].text.split(",") - else: - config._print("No Writer found: " + str(data.select('Writer'))) + if data.select('Summary') != []: + self.summary = data.select('Summary')[0].text + else: + config._print("No Summary found: " + str(data.select('Summary'))) - self.cover = "/image/" + extras.get_cvdb(data.select('Notes')) + ".jpg" - if data.select('Summary') != []: - self.summary = data.select('Summary')[0].text - else: - config._print("No Summary found: " + str(data.select('Summary'))) - + #print(data) + #print(kwargs["links"][0]) + #print(data.select('Series')[0].text) + #print(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) + try: + self.title = "#"+data.select('Number')[0].text.zfill(2) + ": " + data.select('Title')[0].text + " (" + releasedate + ") [" + str(self.size) + "MB]" + except: + self.title = "#"+data.select('Number')[0].text.zfill(2) + " (" + releasedate + ") [" + str(self.size) + "MB]" + #print(self.title) + else: + self.title = kwargs["title"] - #print(data) - #print(kwargs["links"][0]) - #print(data.select('Series')[0].text) - #print(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) - try: - self.title = "#"+data.select('Number')[0].text.zfill(2) + ": " + data.select('Title')[0].text + " (" + releasedate + ") [" + str(self.size) + "MB]" - except: - self.title = "#"+data.select('Number')[0].text.zfill(2) + " (" + releasedate + ") [" + str(self.size) + "MB]" - #print(self.title) else: self.title = kwargs["title"] - - else: - self.title = kwargs["title"] - #self.title = data.select('Title')[0].text + #self.title = data.select('Title')[0].text + except Exception as e: + config._print(e) def get(self, key): return self._data.get(key, None) diff --git a/opds/templates/catalog.opds.jinja2 b/opds/templates/catalog.opds.jinja2 index 11b3d4a..da8ec4d 100644 --- a/opds/templates/catalog.opds.jinja2 +++ b/opds/templates/catalog.opds.jinja2 @@ -27,7 +27,7 @@ {{ entry.title }} {{ entry.id }} - {{ entry.summary }} + m!-- {{ entry.summary }} --> {% for author in entry.authors %} {{ author }}