Major improvements to epub parser
This commit is contained in:
@@ -78,7 +78,7 @@ class ParseCBR:
|
||||
'images_only': True}
|
||||
|
||||
extract_path = os.path.join(self.temp_dir, self.file_md5)
|
||||
contents = collections.OrderedDict()
|
||||
contents = []
|
||||
|
||||
# I'm currently choosing not to keep multiple files in memory
|
||||
self.book.extractall(extract_path)
|
||||
@@ -101,6 +101,6 @@ class ParseCBR:
|
||||
page_name = 'Page ' + str(count + 1)
|
||||
image_path = os.path.join(extract_path, i)
|
||||
|
||||
contents[page_name] = image_path
|
||||
contents.append((page_name, image_path))
|
||||
|
||||
return contents, file_settings
|
||||
|
@@ -81,7 +81,7 @@ class ParseCBZ:
|
||||
'images_only': True}
|
||||
|
||||
extract_path = os.path.join(self.temp_dir, self.file_md5)
|
||||
contents = collections.OrderedDict()
|
||||
contents = []
|
||||
|
||||
# I'm currently choosing not to keep multiple files in memory
|
||||
self.book.extractall(extract_path)
|
||||
@@ -104,6 +104,6 @@ class ParseCBZ:
|
||||
page_name = 'Page ' + str(count + 1)
|
||||
image_path = os.path.join(extract_path, i)
|
||||
|
||||
contents[page_name] = image_path
|
||||
contents.append((page_name, image_path))
|
||||
|
||||
return contents, file_settings
|
||||
|
@@ -35,7 +35,10 @@ class ParseEPUB:
|
||||
|
||||
def read_book(self):
|
||||
self.book_ref = EPUB(self.filename)
|
||||
self.book_ref.read_epub()
|
||||
contents_found = self.book_ref.read_epub()
|
||||
if not contents_found:
|
||||
print('Cannot process: ' + self.filename)
|
||||
return
|
||||
self.book = self.book_ref.book
|
||||
|
||||
def get_title(self):
|
||||
@@ -45,19 +48,16 @@ class ParseEPUB:
|
||||
return self.book['author']
|
||||
|
||||
def get_year(self):
|
||||
return 9999
|
||||
return self.book['year']
|
||||
|
||||
def get_cover_image(self):
|
||||
try:
|
||||
return self.book['cover']
|
||||
except KeyError:
|
||||
return None
|
||||
return self.book['cover']
|
||||
|
||||
def get_isbn(self):
|
||||
return self.book['isbn']
|
||||
|
||||
def get_tags(self):
|
||||
return None
|
||||
return self.book['tags']
|
||||
|
||||
def get_contents(self):
|
||||
extract_path = os.path.join(self.temp_dir, self.file_md5)
|
||||
|
Reference in New Issue
Block a user