Added Writer credits and fixed feed entry

This commit is contained in:
FrederikBaerentsen 2023-01-17 15:01:16 +01:00
parent be7791443a
commit 8a10fba79f
2 changed files with 17 additions and 4 deletions

View File

@ -2,6 +2,8 @@ import zipfile
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
import os import os
from extras import get_size
class Entry(object): class Entry(object):
valid_keys = ( valid_keys = (
"id", "id",
@ -23,7 +25,10 @@ class Entry(object):
"oai_updatedates", "oai_updatedates",
"authors", "authors",
"formats", "formats",
"size",
"links", "links",
"cover",
"covertype"
) )
required_keys = ("id", "title", "links") required_keys = ("id", "title", "links")
@ -53,7 +58,11 @@ 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 = get_size(f, 'mb')
data=BeautifulSoup(s.open('ComicInfo.xml').read(), "xml") data=BeautifulSoup(s.open('ComicInfo.xml').read(), "xml")
#self.cover=s.open('P00001.jpg').read()
self.authors = data.select('Writer')[0].text.split(",")
print(self.authors)
#print(data) #print(data)
#print(kwargs["links"][0]) #print(kwargs["links"][0])
#print(data.select('Series')[0].text) #print(data.select('Series')[0].text)
@ -61,9 +70,9 @@ 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 + ")" self.title = "#"+data.select('Number')[0].text.zfill(2) + ": " + data.select('Title')[0].text + " (" + releasedate + ") [" + str(self.size) + "MB]"
except: except:
self.title = "#"+data.select('Number')[0].text.zfill(2) + " (" + releasedate + ")" 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 = kwargs["title"]
@ -71,8 +80,6 @@ class Entry(object):
else: else:
self.title = kwargs["title"] self.title = kwargs["title"]
#self.title = data.select('Title')[0].text #self.title = data.select('Title')[0].text
def get(self, key): def get(self, key):
return self._data.get(key, None) return self._data.get(key, None)

View File

@ -27,6 +27,12 @@
<entry> <entry>
<title>{{ entry.title }}</title> <title>{{ entry.title }}</title>
<id>{{ entry.id }}</id> <id>{{ entry.id }}</id>
{% for author in entry.authors %}
<author>
<name>{{ author }}</name>
<uri></uri>
</author>
{% endfor %}
{% if entry.updated %} <updated>{{ entry.updated }}</updated> {% endif %} {% if entry.updated %} <updated>{{ entry.updated }}</updated> {% endif %}
{% for link in entry.links %} {% for link in entry.links %}
<link rel="{{ link.rel }}" <link rel="{{ link.rel }}"