def db_add(): metadata = Metadata() db = Db() calibreid = db.get_id(metadata.id) if calibreid is None: c = Calibre() c.insert(metadata) return 0, 'Finished inserting %s.' % options.dir else: return 1, 'Book already exists in Calibre: %s' % options.dir
def db_readmeta(): metadata = Metadata() db = Db() calibreid = db.get_id(metadata.id) if calibreid is None: return 1, 'Book not found in Calibre: %s' % options.dir c = Calibre() c.write_metadata_file(calibreid, metadata.xmlfilename) return 0, 'Finished reading metadata from Calibre for %s.' % options.dir
def db_update(): metadata = Metadata() db = Db() calibreid = db.get_id(metadata.id) if calibreid is None: return 1, 'Book not found in Calibre: %s' % options.dir c = Calibre() c.update_content(calibreid, metadata.bookfile) c.update_metadata(calibreid, metadata) return 0, 'Finished updating in Calibre: %s' % options.dir
def db_meta_pull(): metadata = Metadata() db = Db() calibreid = db.get_id(metadata.id) if calibreid is None: return 1, 'Book not found in Calibre: %s' % options.dir # save metadata from Calibre to metadata.opf c = Calibre() c.write_metadata_file(calibreid, metadata.xmlfilename) # reload metadata from metadata.opf metadata = Metadata() metadata.write_to_book() # push book file with new metadata to Calibre c.update_content(calibreid, metadata.bookfile) return 0, "Finished updating content and metadata file from Calibre's metadata for %s." % options.dir