Skip to content

Commit

Permalink
update EXTH header only once
Browse files Browse the repository at this point in the history
  • Loading branch information
xxyzz committed Dec 22, 2020
1 parent a07d4b3 commit 91933b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def done(self, job):

# send files to device
for book_id in self.ids:
data = check_metadata(self.gui.current_db.new_api, book_id)
data = check_metadata(self.gui.current_db.new_api,
book_id, False)
if data is None:
continue
send(self.gui, (book_id, ) + data)
Expand Down
4 changes: 2 additions & 2 deletions metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from calibre_plugins.worddumb.asin import get_asin


def check_metadata(db, book_id):
def check_metadata(db, book_id, update_exth=True):
# Get the current metadata for this book from the db
mi = db.get_metadata(book_id)
fmts = db.formats(book_id)
Expand Down Expand Up @@ -41,7 +41,7 @@ def check_metadata(db, book_id):
mi.set_identifier('mobi-asin', asin)
db.set_metadata(book_id, mi)

if fmt.lower() in ['mobi', 'azw3']:
if fmt.lower() in ['mobi', 'azw3'] and update_exth:
with open(book_path, 'r+b') as stream:
mu = UpdateMobiEXTH(stream)
mu.update(mi, asin)
Expand Down

0 comments on commit 91933b4

Please sign in to comment.