Bugfix write metadata

Bugfix change of custom column now sets updates the book timestamp
This commit is contained in:
Ozzie Isaacs 2023-03-19 17:23:05 +01:00
commit 7ade4615a4
3 changed files with 17 additions and 9 deletions

View File

@ -1123,9 +1123,10 @@ def edit_cc_data(book_id, book, to_save, cc):
cc_db_value = None
if to_save[cc_string].strip():
if c.datatype in ['int', 'bool', 'float', "datetime", "comments"]:
changed, to_save = edit_cc_data_value(book_id, book, c, to_save, cc_db_value, cc_string)
change, to_save = edit_cc_data_value(book_id, book, c, to_save, cc_db_value, cc_string)
else:
changed, to_save = edit_cc_data_string(book, c, to_save, cc_db_value, cc_string)
change, to_save = edit_cc_data_string(book, c, to_save, cc_db_value, cc_string)
changed |= change
else:
if cc_db_value is not None:
# remove old cc_val

View File

@ -173,10 +173,13 @@ class TaskBackupMetadata(CalibreTask):
date = etree.SubElement(metadata, PURL + "date", nsmap=NSMAP)
date.text = '{d.year:04}-{d.month:02}-{d.day:02}T{d.hour:02}:{d.minute:02}:{d.second:02}'.format(d=book.pubdate)
if book.comments:
if book.comments and book.comments[0].text:
for b in book.comments:
description = etree.SubElement(metadata, PURL + "description", nsmap=NSMAP)
description.text = b.text
for b in book.publishers:
publisher = etree.SubElement(metadata, PURL + "publisher", nsmap=NSMAP)
publisher.text = str(b.name)
if not book.languages:
language = etree.SubElement(metadata, PURL + "language", nsmap=NSMAP)
language.text = self.export_language
@ -198,6 +201,10 @@ class TaskBackupMetadata(CalibreTask):
etree.SubElement(metadata, "meta", name="calibre:series_index",
content=str(book.series_index),
nsmap=NSMAP)
if len(book.ratings) and book.ratings[0].rating > 0:
etree.SubElement(metadata, "meta", name="calibre:rating",
content=str(book.ratings[0].rating),
nsmap=NSMAP)
etree.SubElement(metadata, "meta", name="calibre:timestamp",
content='{d.year:04}-{d.month:02}-{d.day:02}T{d.hour:02}:{d.minute:02}:{d.second:02}'.format(
d=book.timestamp),
@ -211,8 +218,8 @@ class TaskBackupMetadata(CalibreTask):
extra = None
cc_entry = getattr(book, "custom_column_" + str(cc.id))
if cc_entry.__len__():
value = cc_entry[0].get("value")
extra = cc_entry[0].get("extra")
value = cc_entry[0].value
extra = cc_entry[0].extra if hasattr(cc_entry[0], "extra") else None
etree.SubElement(metadata, "meta", name="calibre:user_metadata:#{}".format(cc.label),
content=cc.to_json(value, extra, sequence),
nsmap=NSMAP)

View File

@ -47,9 +47,9 @@ install_requires =
backports_abc>=0.4
Flask>=1.0.2,<2.3.0
iso-639>=0.4.5,<0.5.0
PyPDF==3.4.0
PyPDF>=3.0.0,<3.6.0
pytz>=2016.10
requests>=2.11.1,<2.28.0
requests>=2.11.1,<2.29.0
SQLAlchemy>=1.3.0,<2.0.0
tornado>=4.1,<6.3
Wand>=0.4.4,<0.7.0
@ -58,7 +58,7 @@ install_requires =
flask-wtf>=0.14.2,<1.2.0
chardet>=3.0.0,<4.1.0
advocate>=1.0.0,<1.1.0
Flask-Limiter>=2.3.0,<3.3.0
Flask-Limiter>=2.3.0,<3.4.0
[options.extras_require]
@ -95,7 +95,7 @@ metadata =
beautifulsoup4>=4.0.1,<4.12.0
cchardet>=2.0.0,<2.2.0
comics =
natsort>=2.2.0,<8.3.0
natsort>=2.2.0,<8.4.0
comicapi>=2.2.0,<2.3.0
kobo =
jsonschema>=3.2.0,<4.18.0