diff --git a/cps/editbooks.py b/cps/editbooks.py index 9ce5ce47..06c8b12b 100755 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -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 diff --git a/cps/tasks/metadata_backup.py b/cps/tasks/metadata_backup.py index 35d51d75..e76df95e 100644 --- a/cps/tasks/metadata_backup.py +++ b/cps/tasks/metadata_backup.py @@ -173,7 +173,7 @@ 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 @@ -201,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), @@ -214,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)