kindle manager
This commit is contained in:
142
mobimaster/README.md
Executable file
142
mobimaster/README.md
Executable file
@@ -0,0 +1,142 @@
|
||||
# mobi - library for unpacking unencrypted mobi files
|
||||
|
||||
## extrct structure
|
||||
|
||||
```
|
||||
def extract(infile):
|
||||
|
|
||||
def unpackBook(infile, tempdir, epubver="A")
|
||||
```
|
||||
|
||||
## unpackBook structure
|
||||
```
|
||||
def unpackBook( infile, outdir, apnxfile=None, epubver="2", use_hd=False, dodump=False, dowriteraw=False, dosplitcombos=False,)
|
||||
|
|
||||
# 制作目录结构 unpack_structure
|
||||
files = fileNames(infile, outdir)
|
||||
#process the PalmDoc database header and verify it is a mobi
|
||||
# sect 包含什么?
|
||||
sect = Sectionizer(infile)
|
||||
|
|
||||
# CG mobi header, if K8 hasK8 = True
|
||||
mh = MobiHeader(sect, 0)
|
||||
|
|
||||
# if this is a combination mobi7-mobi8 file split them up
|
||||
# 默认关闭 SPLIT_COMBO_MOBIS = False
|
||||
# ???
|
||||
mobisplit = mobi_split(infile)
|
||||
# k8, 制作k8目录结构
|
||||
files.makeK8Struct()
|
||||
|
|
||||
# mhlst - mobi_header list
|
||||
# 关键!! 处理所有电子书
|
||||
def process_all_mobi_headers( files, apnxfile, sect, mhlst, K8Boundary, False, epubver, use_hd)
|
||||
|
|
||||
# 依据传入section,处理header,放入header_K8.dat/header_OR.dat/header.dat
|
||||
|
|
||||
# first handle all of the different resource sections: images, resources, fonts, and etc
|
||||
# build up a list of image names to use to postprocess the ebook
|
||||
|
||||
```
|
||||
ncx_data K7 position/150 = real page number
|
||||
ncx_data K8 包含目录结构
|
||||
```
|
||||
|
||||
https://www.mobileread.com/forums/showthread.php?t=61986&page=78
|
||||
It is a compiled ebook format that uses a palm database structure - a set of starting offsets to binary data referred to either as sections or records depending on who you ask. What KindleUnpack does is examine these binary sections, identifies any sections that are headers and then use them to identify starting section numbers where images are stored, text is stored, index information, and etc. and then extract them to files. The data from these files are used to create html3.2 code that can be used to input back into kindlegen for the older mobi 7 pieces and used to create an epub-like structure for the kf8 pieces. If you actually want to see the rawml you can dump that as well.
|
||||
|
||||
The header sections also have EXTH records that contain the MetaData information. If you want to understand the exact layout of the mobi file, simply run DumpMobiHeader_v018.py or later and look at the description of what is stored in each section of the palm database file.
|
||||
|
||||
For joint mobis, the images are not duplicated, they are stored after the mobi7 header and before the kf8 header. Later mobis can also have a completely separate container of HDImages and placeholders.
|
||||
|
||||
When Kindleunpack unpacks image sections (and fonts and RESC sections) it stores them all in a mobi 7 folder and copies the correct piecs to the mobi 8 folder as needed. When Kindleunpack unpacks from the HD Container, it will store these images in their own HDImage folder as they can notbe shared with a mobi 7. There is a switch to have the HDImages overwrite their low resolution cousins.
|
||||
|
||||
So please run DumpMobiHeader and examine the section map to see what is actually being stored i side the palm database structure.
|
||||
|
||||
If you have further questions, post the output of DumpMobiHeader from running on your mobi so that I understand exactly what it is you are askng. It will even work on DRMd ebooks since the headers themselves and most images are not typically encrypted.
|
||||
|
||||
Hope this helps,
|
||||
|
||||
KevinH
|
||||
KevinH is offline Reply With Quote
|
||||
Old 07-05-2015, 07:37 PM #1169
|
||||
|
||||
|
||||
[](https://pypi.python.org/pypi/mobi/)
|
||||
[](https://pepy.tech/project/mobi)
|
||||
|
||||
> A fork of [KindleUnpack](https://github.com/kevinhendricks/KindleUnpack) which removes the GUI part and makes it available as a python library via [PyPi](https://pypi.org/project/mobi/) for easy unpacking of mobi files.
|
||||
|
||||
## Usage
|
||||
|
||||
### As library
|
||||
|
||||
```python
|
||||
import mobi
|
||||
|
||||
tempdir, filepath = mobi.extract("mybook.mobi")
|
||||
```
|
||||
|
||||
'tempdir' is the path where the mobi is unpacked
|
||||
'filepath' is the path to either an epub, html or pdf file depending on the mobi type
|
||||
|
||||
| NOTE: You are responsible to delete the generated tempdir! |
|
||||
| --- |
|
||||
|
||||
### From the command line
|
||||
|
||||
The installer also creates a console script entrypoint that wraps the original KindleUnpack
|
||||
|
||||
```console
|
||||
$ mobiunpack
|
||||
KindleUnpack v0.82
|
||||
Based on initial mobipocket version Copyright © 2009 Charles M. Hannum <root@ihack.net>
|
||||
Extensive Extensions and Improvements Copyright © 2009-2014
|
||||
by: P. Durrant, K. Hendricks, S. Siebert, fandrieu, DiapDealer, nickredding, tkeo.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, version 3.
|
||||
|
||||
Description:
|
||||
Unpacks an unencrypted Kindle/MobiPocket ebook to html and images
|
||||
or an unencrypted Kindle/Print Replica ebook to PDF and images
|
||||
into the specified output folder.
|
||||
Usage:
|
||||
mobiunpack -r -s -p apnxfile -d -h --epub_version= infile [outdir]
|
||||
Options:
|
||||
-h print this help message
|
||||
-i use HD Images, if present, to overwrite reduced resolution images
|
||||
-s split combination mobis into mobi7 and mobi8 ebooks
|
||||
-p APNXFILE path to an .apnx file associated with the azw3 input (optional)
|
||||
--epub_version= specify epub version to unpack to: 2, 3, A (for automatic) or
|
||||
F (force to fit to epub2 definitions), default is 2
|
||||
-d dump headers and other info to output and extra files
|
||||
-r write raw data to the output folder
|
||||
```
|
||||
|
||||
### [0.3.1] - 2020-06-27
|
||||
- Fix pypi link
|
||||
- Update dependencies
|
||||
|
||||
### [0.3.0] - 2020-03-02
|
||||
|
||||
- Add support for mobi7 only files
|
||||
- Add experimental support for mobi print replica files
|
||||
- Add support for file-like objects
|
||||
|
||||
|
||||
### [0.2.0] - 2020-03-02
|
||||
|
||||
- Minimal working 'extract' function and 'mobiunpack' console wrapper
|
||||
- Replace most print calls with logging
|
||||
|
||||
### [0.1.0] - 2020-03-02
|
||||
|
||||
- Empty package registered on pypi
|
||||
|
||||
## License
|
||||
|
||||
GPL-3.0-only
|
||||
|
||||
All credits for the hard work go to https://github.com/kevinhendricks/KindleUnpack
|
||||
|
||||
Reference in New Issue
Block a user