This tool is designed to fix cover display issues on the new Kindle Colorsoft by ensuring the correct Kindle ASIN is present in .opf
files within your Calibre library. Since the Colorsoft model fetches covers directly from Amazon servers, the correct Kindle ASIN is necessary for covers to load properly.
The tool performs the following actions:
- Extracts ASINs: Reads
.opf
files in your Calibre library to pull existing ASINs. - Scrapes Amazon: Uses Selenium to scrape Amazon for the correct Kindle ASIN, if needed.
- Updates Metadata: Writes the Kindle ASIN back into the
.opf
files to ensure the correct cover can be fetched. - Updates Database: Modifies entries in the Calibre database to store the updated ASIN information.
- Python 3.x
- Calibre with
.opf
metadata files for your books - Selenium and webdriver-manager to handle Amazon scraping
- SQLite3 for interacting with the Calibre database
- ChromeDriver for Selenium scraping (automatically managed by
webdriver-manager
)
- Clone this repository.
- Install dependencies using the
requirements.txt
file:pip install -r requirements.txt
- Ensure Chrome is installed (or modify the code to use a different browser if preferred).
The tool works by executing various subcommands. Below are details on each subcommand and its purpose.
-
Extract ASINs: Scans
.opf
files in your Calibre library to pull ASIN identifiers.python asin_fixer.py extract <root_dir> <output_file>
root_dir
: Directory to start scanning (default is the current directory).output_file
: File to save the extracted ASINs (default isamazon_ids.txt
).
-
Scrape Amazon for Kindle ASINs: Looks up Kindle ASINs on Amazon and updates the
input_file
.python asin_fixer.py scrape <input_file>
input_file
: File containing old ASINs and paths, as created by theextract
command.
-
Update
.opf
Files: Writes the newly found Kindle ASINs back into the.opf
files.python asin_fixer.py update <mapping_file>
mapping_file
: File containing old and new ASINs, as created by thescrape
command.
-
Update Database: Updates the Calibre database with the new ASINs from
.opf
files.python asin_fixer.py update_db <db_file>
db_file
: Path to your Calibre database file.
-
Clean Temporary Data: Removes lines with new ASINs and trailing commas from the input file.
python asin_fixer.py clean <input_file>
input_file
: File containing ASIN mappings, typically created during extraction and scraping.
-
Extract ASINs from .opf files:
python asin_fixer.py extract /path/to/calibre/library amazon_ids.txt
-
Scrape Amazon for updated Kindle ASINs:
python asin_fixer.py scrape amazon_ids.txt
-
Update .opf files with new ASINs:
python asin_fixer.py update amazon_ids.txt
-
Update the Calibre database with new ASINs:
python asin_fixer.py update_db /path/to/calibre/metadata.db
-
Clean up temporary data if needed:
python asin_fixer.py clean amazon_ids.txt
- This script uses Selenium for web scraping, so it will open a Chrome browser window (unless run in headless mode).
- Captcha may be required during Amazon scraping; the script will pause and wait for manual captcha resolution if detected.
- This tool is optimized for Kindle books with a corresponding ASIN on Amazon; results may vary if books don’t have Kindle variants.
This project is licensed under the MIT License.