mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Add a tweak in Preferences->Tweaks to exclude some fields when using the Edit metadata->Copy metadata/paste actions
This commit is contained in:
parent
8f0d9cc028
commit
6cd33e110e
@ -560,3 +560,10 @@ cover_drop_exclude = ()
|
||||
# new Saved search is shown in the Search bar. If you would like to have the
|
||||
# old Saved searches box with its two buttons back, set this tweak to True.
|
||||
show_saved_search_box = False
|
||||
|
||||
#: Exclude fields when copy/pasting metadata
|
||||
# You can ask calibre to not paste some metadata fields when using the
|
||||
# Edit metadata->Copy metadata/Paste metadata actions. For example,
|
||||
# exclude_fields_on_paste = ['cover', 'timestamp', '#mycolumn']
|
||||
# to prevent pasting of the cover, Date and custom column, mycolumn.
|
||||
exclude_fields_on_paste = []
|
||||
|
@ -117,6 +117,10 @@ class Metadata(object):
|
||||
except:
|
||||
return True
|
||||
|
||||
def set_null(self, field):
|
||||
null_val = copy.copy(NULL_VALUES.get(field))
|
||||
setattr(self, field, null_val)
|
||||
|
||||
def __getattribute__(self, field):
|
||||
_data = object.__getattribute__(self, '_data')
|
||||
if field in SIMPLE_GET:
|
||||
|
@ -19,6 +19,7 @@ from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.ebooks.metadata import authors_to_string
|
||||
from calibre.ebooks.metadata.book.base import Metadata
|
||||
from calibre.ebooks.metadata.opf2 import OPF, metadata_to_opf
|
||||
from calibre.utils.config import tweaks
|
||||
from calibre.utils.date import is_date_undefined
|
||||
from calibre.utils.icu import sort_key
|
||||
from calibre.db.errors import NoSuchFormat
|
||||
@ -141,7 +142,12 @@ class EditMetadataAction(InterfaceAction):
|
||||
data = bytes(md.data('application/calibre-book-metadata'))
|
||||
mi = OPF(BytesIO(data), populate_spine=False, read_toc=False, try_to_guess_cover=False).to_book_metadata()
|
||||
mi.application_id = mi.uuid_id = None
|
||||
cover = md.imageData()
|
||||
exclude = set(tweaks['exclude_fields_on_paste'])
|
||||
paste_cover = 'cover' not in exclude
|
||||
cover = md.imageData() if paste_cover else None
|
||||
exclude.discard('cover')
|
||||
for field in exclude:
|
||||
mi.set_null(field)
|
||||
db = self.gui.current_db
|
||||
book_ids = {db.id(r.row()) for r in rows}
|
||||
for book_id in book_ids:
|
||||
|
Loading…
x
Reference in New Issue
Block a user