View Single Post
Old 03-10-2021, 10:31 AM   #4
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
Posts: 7,094
Karma: 92190113
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
Quote:
Originally Posted by xxyzz View Post
I tried to edit ASIN of KFX book by doing this, but nothing happened, is this the right way?
Code:
from calibre_plugins.kfx_input.kfxlib import YJ_Book
book = YJ_Book('book.kfx')
metadata = book.get_metadata()
metadata.asin = 'BBBBB'
book.set_yj_metadata_to_book(metadata)
set_yj_metadata_to_book is an internal function, not meant to be called directly. You should do something like this instead:

Code:
    book = YJ_Book("book.kfx")
    md = YJ_Metadata()
    md.asin = "B000000000"
    md.cde_content_type = "EBOK"
    book.decode_book(set_metadata=md)
    
    new_kfx_data = book.convert_to_single_kfx()
    with io.open("new_book.kfx", "wb") as new_file:
        new_file.write(new_kfx_data)
Also see "metadata_writer.py" in the KFX Output plugin for an example of how to set metadata to KFX format.

Quote:
Originally Posted by xxyzz View Post
I think the 116 line of yj_metabata.py should be:
Code:
if yj_metadata.asin is None:
That line is coded as I intended. A value of "True" as a special flag indicating that a random ASIN should be generated. A value of "None" means do not change the ASIN.

Quote:
Originally Posted by xxyzz View Post
And I wonder why it's call yj_book, is this some abbreviation?
"YJ" is short for "Yellow Jersey" the Amazon code name for KFX format and related technology.

Quote:
Originally Posted by xxyzz View Post
I forget to ask about srl and erl in book_metadata table: https://github.com/xxyzz/WordDumb/bl...ntitiesasinasc
SRL is the start reading location, the position where a new book should open for the first time. ERL is the end reading location, the position at which the "before you go" popup screen should occur when reading. They mark the boundaries of the main content of the book.
jhowell is offline   Reply With Quote