View Single Post
Old 10-02-2023, 05:49 AM   #16
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,450
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by kovidgoyal View Post
@charles: Yes that's fine.
PR pushed

@kjdavies:
Once the above PR is accepted (it is accepted), and once it is released if you are not running from source, this script merges metadata from N books into one.

EDIT: merge_book_metadata() was moved to become a db new_api method. I changed the script.

Code:
from calibre.db.legacy import LibraryDatabase

if not LibraryDatabase.exists_at(sys.argv[1]):
    print(f'no such library or not a library: {sys.argv[1]}')
    exit()
    
db = LibraryDatabase(sys.argv[1])

ids = sys.argv[2:]
if len(ids) < 2:
    print('must supply at least 2 ids')

ids = [int(i) for i in ids]
dest_id = ids[0]
ids = ids[1:]

db.new_api.merge_book_metadata(dest_id, ids)
You run it with
Code:
calibre-debug -e path-to-script path-to-library book_id book_id [book_id *]
The first book_id is the target for the merge.

Last edited by chaley; 10-02-2023 at 06:30 AM. Reason: merge_book_metadata became a db api method
chaley is offline   Reply With Quote