1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-29 21:09:58 +00:00

Merge branch 'embed_metadata_on_convert' into embed_metadata_on_download

This commit is contained in:
Thore Schillmann 2022-07-14 13:39:58 +00:00
commit e176d63ca6

View File

@ -64,15 +64,20 @@ class TaskConvert(CalibreTask):
data = worker_db.get_book_format(self.book_id, self.settings['old_book_format']) data = worker_db.get_book_format(self.book_id, self.settings['old_book_format'])
df = gdriveutils.getFileFromEbooksFolder(cur_book.path, df = gdriveutils.getFileFromEbooksFolder(cur_book.path,
data.name + "." + self.settings['old_book_format'].lower()) data.name + "." + self.settings['old_book_format'].lower())
if df: df_cover = gdriveutils.getFileFromEbooksFolder(cur_book.path, "cover.jpg")
if df and df_cover:
datafile = os.path.join(config.config_calibre_dir, datafile = os.path.join(config.config_calibre_dir,
cur_book.path, cur_book.path,
data.name + u"." + self.settings['old_book_format'].lower()) data.name + u"." + self.settings['old_book_format'].lower())
datafile_cover = os.path.join(config.config_calibre_dir,
cur_book.path, "cover.jpg")
if not os.path.exists(os.path.join(config.config_calibre_dir, cur_book.path)): if not os.path.exists(os.path.join(config.config_calibre_dir, cur_book.path)):
os.makedirs(os.path.join(config.config_calibre_dir, cur_book.path)) os.makedirs(os.path.join(config.config_calibre_dir, cur_book.path))
df.GetContentFile(datafile) df.GetContentFile(datafile)
df_cover.GetContentFile(datafile_cover)
worker_db.session.close() worker_db.session.close()
else: else:
# ToDo Include cover in error handling
error_message = _(u"%(format)s not found on Google Drive: %(fn)s", error_message = _(u"%(format)s not found on Google Drive: %(fn)s",
format=self.settings['old_book_format'], format=self.settings['old_book_format'],
fn=data.name + "." + self.settings['old_book_format'].lower()) fn=data.name + "." + self.settings['old_book_format'].lower())
@ -82,6 +87,7 @@ class TaskConvert(CalibreTask):
filename = self._convert_ebook_format() filename = self._convert_ebook_format()
if config.config_use_google_drive: if config.config_use_google_drive:
os.remove(self.file_path + u'.' + self.settings['old_book_format'].lower()) os.remove(self.file_path + u'.' + self.settings['old_book_format'].lower())
os.remove(os.path.join(config.config_calibre_dir, cur_book.path, "cover.jpg"))
if filename: if filename:
if config.config_use_google_drive: if config.config_use_google_drive: