mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Refuse to set metadata in DRMed MOBI files as this can lead to files that dont work on the device
This commit is contained in:
parent
9c3062a4b5
commit
3ea924b1d3
@ -81,6 +81,7 @@ class MetadataUpdater(object):
|
|||||||
type = self.type = data[60:68]
|
type = self.type = data[60:68]
|
||||||
self.nrecs, = unpack('>H', data[76:78])
|
self.nrecs, = unpack('>H', data[76:78])
|
||||||
record0 = self.record0 = self.record(0)
|
record0 = self.record0 = self.record(0)
|
||||||
|
self.encryption_type, = unpack('>H', record0[12:14])
|
||||||
codepage, = unpack('>I', record0[28:32])
|
codepage, = unpack('>I', record0[28:32])
|
||||||
self.codec = 'utf-8' if codepage == 65001 else 'cp1252'
|
self.codec = 'utf-8' if codepage == 65001 else 'cp1252'
|
||||||
image_base, = unpack('>I', record0[108:112])
|
image_base, = unpack('>I', record0[108:112])
|
||||||
@ -134,6 +135,8 @@ class MetadataUpdater(object):
|
|||||||
if self.thumbnail_record is not None:
|
if self.thumbnail_record is not None:
|
||||||
recs.append((202, pack('>I', self.thumbnail_rindex)))
|
recs.append((202, pack('>I', self.thumbnail_rindex)))
|
||||||
exth = StringIO()
|
exth = StringIO()
|
||||||
|
if getattr(self, 'encryption_type', -1) != 0:
|
||||||
|
raise MobiError('Setting metadata in DRMed MOBI files is not supported.')
|
||||||
for code, data in recs:
|
for code, data in recs:
|
||||||
exth.write(pack('>II', code, len(data) + 8))
|
exth.write(pack('>II', code, len(data) + 8))
|
||||||
exth.write(data)
|
exth.write(data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user