Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
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: 11,793
Karma: 7029971
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
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: 109
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
Advert
Old 10-06-2023, 12:14 AM   #18
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: 109
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
@chaley, I just downloaded and installed 6.28 (Windows 10).

I tried to merge two titles via the GUI and I get an error message:

Code:
calibre, version 6.28.0
ERROR: Unhandled exception: <b>AttributeError</b>:'tuple' object has no attribute 'extend'

calibre 6.28  embedded-python: True
Windows-10-10.0.19045-SP0 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.19045')
Python 3.10.1
Windows: ('10', '10.0.19045', 'SP0', 'Multiprocessor Free')
Interface language: None
Successfully initialized third party plugins: Action Chains (1, 18, 12) && Babelio_db (0, 8, 3) && Baen (1, 1, 0) && Barnes & Noble (1, 5, 2) && CalibreSpy (1, 0, 92) && Category Tags (0, 2, 8) && Comicvine (0, 14, 1) && Consolidate All Library Metadata (2, 0, 46) && Count Pages (1, 13, 2) && Embed Comic Metadata (1, 6, 6) && Entities Manager (1, 0, 19) && Extract ISBN (1, 6, 0) && FanFicFare (4, 28, 0) && Fantastic Fiction (1, 6, 4) && Fantastic Fiction Adults (1, 3, 0) && FictionDB (1, 4, 1) && Find Duplicates (1, 10, 8) && Generate Cover (2, 3, 3) && Goodreads (1, 7, 9) && Highlights to Obsidian (1, 4, 0) && Job Spy (1, 0, 239) && Manage Series (1, 5, 1) && Mass Search-Replace (1, 7, 4) && Open With (1, 8, 1) && Quality Check (1, 13, 6) && Reading List (1, 15, 1) && Recipe Reader (1, 0, 1) && Smashwords Metadata (1, 0, 2) && View Manager (1, 10, 2) && all recipes Recipe Reader (1, 0, 2)
Traceback (most recent call last):
  File "calibre\gui2\actions\edit_metadata.py", line 676, in merge_books
  File "calibre\gui2\actions\edit_metadata.py", line 734, in merge_metadata
  File "calibre\db\cache.py", line 85, in call_func_with_lock
  File "calibre\db\cache.py", line 3260, in merge_book_metadata
AttributeError: 'tuple' object has no attribute 'extend'
kjdavies is offline   Reply With Quote
Old 10-06-2023, 08:20 AM   #19
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: 11,793
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by kjdavies View Post
@chaley, I just downloaded and installed 6.28 (Windows 10).

I tried to merge two titles via the GUI and I get an error message:

Code:
calibre, version 6.28.0
ERROR: Unhandled exception: <b>AttributeError</b>:'tuple' object has no attribute 'extend'

calibre 6.28  embedded-python: True
Windows-10-10.0.19045-SP0 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.19045')
Python 3.10.1
Windows: ('10', '10.0.19045', 'SP0', 'Multiprocessor Free')
Interface language: None
Successfully initialized third party plugins: Action Chains (1, 18, 12) && Babelio_db (0, 8, 3) && Baen (1, 1, 0) && Barnes & Noble (1, 5, 2) && CalibreSpy (1, 0, 92) && Category Tags (0, 2, 8) && Comicvine (0, 14, 1) && Consolidate All Library Metadata (2, 0, 46) && Count Pages (1, 13, 2) && Embed Comic Metadata (1, 6, 6) && Entities Manager (1, 0, 19) && Extract ISBN (1, 6, 0) && FanFicFare (4, 28, 0) && Fantastic Fiction (1, 6, 4) && Fantastic Fiction Adults (1, 3, 0) && FictionDB (1, 4, 1) && Find Duplicates (1, 10, 8) && Generate Cover (2, 3, 3) && Goodreads (1, 7, 9) && Highlights to Obsidian (1, 4, 0) && Job Spy (1, 0, 239) && Manage Series (1, 5, 1) && Mass Search-Replace (1, 7, 4) && Open With (1, 8, 1) && Quality Check (1, 13, 6) && Reading List (1, 15, 1) && Recipe Reader (1, 0, 1) && Smashwords Metadata (1, 0, 2) && View Manager (1, 10, 2) && all recipes Recipe Reader (1, 0, 2)
Traceback (most recent call last):
  File "calibre\gui2\actions\edit_metadata.py", line 676, in merge_books
  File "calibre\gui2\actions\edit_metadata.py", line 734, in merge_metadata
  File "calibre\db\cache.py", line 85, in call_func_with_lock
  File "calibre\db\cache.py", line 3260, in merge_book_metadata
AttributeError: 'tuple' object has no attribute 'extend'
This is a regression introduced when merge books became a calibre db API method. The exception happens when both the source and the destination of a multiple-value custom column (like tags) have values.

It is fixed in source.
chaley is offline   Reply With Quote
Old 10-06-2023, 12:26 PM   #20
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: 109
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
Quote:
Originally Posted by chaley View Post
This is a regression introduced when merge books became a calibre db API method. The exception happens when both the source and the destination of a multiple-value custom column (like tags) have values.

It is fixed in source.
Thank you.

Does it still integrate the tags (resulting in the union of the two sets)?
kjdavies is offline   Reply With Quote
Advert
Old 10-06-2023, 12:28 PM   #21
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: 11,793
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by kjdavies View Post
Thank you.

Does it still integrate the tags (resulting in the union of the two sets)?
No, the tags are not modified. As far as I can see all the other metadata is merged.

EDIT: Merging stops at the error, which means that if there are multiple source books then all metadata for some books might not be merged into the destination.

Last edited by chaley; 10-06-2023 at 12:58 PM.
chaley is offline   Reply With Quote
Old 10-06-2023, 08:30 PM   #22
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: 109
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
Quote:
Originally Posted by chaley View Post
No, the tags are not modified. As far as I can see all the other metadata is merged.

EDIT: Merging stops at the error, which means that if there are multiple source books then all metadata for some books might not be merged into the destination.
If I'm not mistaken -- and I've watched this happen tens of thousands of times while deduping my libraries, with tag fields involved -- when merging two titles in the library, the result contains the union of the tags.

That is, if TitleA has tag1, tag2, tag3, and TitleB has tag2, tag3, tag4, then after the merge I'm left with TitleA with title and author and cover of the original TitleA[1] and tag1, tag2, tag3, tag4.

[1] unless null -- if author is Unknown or there is no cover in TitleA, but TitleB has author or cover, the resulting TitleA will pick them up from the TitleB entry.

IOW, if merge still has the same behavior but different access, we're all good.
kjdavies is offline   Reply With Quote
Old 10-06-2023, 10:47 PM   #23
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,024
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
yes, th ebehavior has not changed.
kovidgoyal is offline   Reply With Quote
Old 10-07-2023, 03:02 AM   #24
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: 11,793
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by kjdavies View Post
IOW, if merge still has the same behavior but different access, we're all good.
Quote:
Originally Posted by kovidgoyal View Post
yes, th ebehavior has not changed.
This is true once the regression fix is released. Until then, merging multiple value custom columns where both the source and destination have values will fail and no yet-to-be-processed source books will be considered.
chaley is offline   Reply With Quote
Old 10-07-2023, 11:22 AM   #25
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: 11,793
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
The regression is fixed in calibre release 6.28.1.
chaley is offline   Reply With Quote
Old 10-07-2023, 12:28 PM   #26
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: 109
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
Quote:
Originally Posted by chaley View Post
This is true once the regression fix is released. Until then, merging multiple value custom columns where both the source and destination have values will fail and no yet-to-be-processed source books will be considered.
That seems like such a weird edge case, I can see how it could be overlooked.

Thanks for confirming, @chaley and @kovidgoyal.
kjdavies is offline   Reply With Quote
Old 10-08-2023, 02:53 AM   #27
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 6,289
Karma: 11806357
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
Quote:
Originally Posted by chaley View Post
The regression is fixed in calibre release 6.28.1.
Thank you. Yes, it's fixed (as I was running calibre 6.28 and it has failed at the first merge I've tried, but it works running calibre 6.28.1).
Terisa de morgan is offline   Reply With Quote
Old 10-08-2023, 12:45 PM   #28
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: 109
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
Quote:
Originally Posted by chaley View Post
The regression is fixed in calibre release 6.28.1.
So I see and confirm. Thanks @chaley.
kjdavies is offline   Reply With Quote
Reply

Tags
calibredb, merge


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Installer for calibredb only? Freakeao Calibre 3 12-09-2020 09:19 PM
Merge books, how to select FIRST book or MERGE metadata? rboatright Library Management 11 08-20-2016 11:01 AM
commandline calibredb Divingduck Calibre 2 07-31-2014 05:18 AM
calibredb iomari Calibre 6 10-10-2011 08:35 AM
Merge feature request (different merge) Tarran Calibre 1 05-24-2010 10:57 AM


All times are GMT -4. The time now is 06:48 PM.


MobileRead.com is a privately owned, operated and funded community.