Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE
calibre.8743
update_kindle_driver.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File update_kindle_driver.patch of Package calibre.8743
From 5a4e322ab2b4103c8a388f451c20c6ea969ebe91 Mon Sep 17 00:00:00 2001 From: j-howell <jhowell@acm.org> Date: Sun, 5 Aug 2018 17:14:52 -0400 Subject: [PATCH] Create thumbnail images on Kindle for KFX fomrat --- src/calibre/devices/kindle/driver.py | 16 +++++++++++++--- src/calibre/ebooks/metadata/kfx.py | 11 +++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/calibre/devices/kindle/driver.py b/src/calibre/devices/kindle/driver.py index c6635a873f..a20754ba0d 100644 --- a/src/calibre/devices/kindle/driver.py +++ b/src/calibre/devices/kindle/driver.py @@ -463,18 +463,28 @@ def upload_cover(self, path, filename, metadata, filepath): self.upload_apnx(path, filename, metadata, filepath) def thumbpath_from_filepath(self, filepath): + from calibre.ebooks.metadata.kfx import (CONTAINER_MAGIC, read_book_key_kfx) from calibre.ebooks.mobi.reader.headers import MetadataHeader from calibre.utils.logging import default_log thumb_dir = os.path.join(self._main_prefix, 'system', 'thumbnails') if not os.path.exists(thumb_dir): return with lopen(filepath, 'rb') as f: - mh = MetadataHeader(f, default_log) - if mh.exth is None or not mh.exth.uuid or not mh.exth.cdetype: + is_kfx = f.read(4) == CONTAINER_MAGIC + f.seek(0) + if is_kfx: + uuid,cdetype = read_book_key_kfx(f) + else: + mh = MetadataHeader(f, default_log) + if mh.exth is None: + return + uuid = mh.exth.uuid + cdetype = mh.exth.cdetype + if not uuid or not cdetype: return return os.path.join(thumb_dir, 'thumbnail_{uuid}_{cdetype}_portrait.jpg'.format( - uuid=mh.exth.uuid, cdetype=mh.exth.cdetype)) + uuid=uuid, cdetype=cdetype)) def upload_kindle_thumbnail(self, metadata, filepath): coverdata = getattr(metadata, 'thumbnail', None) diff --git a/src/calibre/ebooks/metadata/kfx.py b/src/calibre/ebooks/metadata/kfx.py index 66eeadec71..b3252de99b 100644 --- a/src/calibre/ebooks/metadata/kfx.py +++ b/src/calibre/ebooks/metadata/kfx.py @@ -278,6 +278,17 @@ def dump_metadata(m): pprint(d) +def read_book_key_kfx(stream, read_cover=True): + ' Read the metadata.kfx file that is found in the sdr book folder for KFX files ' + c = Container(stream.read()) + m = extract_metadata(c.decode()) + + def val(x): + return m[x][0] if x in m else '' + + return (val('content_id') or val('ASIN'), val('cde_content_type')) + + def read_metadata_kfx(stream, read_cover=True): ' Read the metadata.kfx file that is found in the sdr book folder for KFX files ' c = Container(stream.read())
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor