View Single Post
Old 10-05-2023, 11:13 PM   #17
kjdavies
Zealot
kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.
 
Posts: 112
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
Quote:
Originally Posted by chaley View Post
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.
Sweet, thanks @chaley. I'll check it out as soon as I can see it.
kjdavies is offline   Reply With Quote