Skip to content

Instantly share code, notes, and snippets.

@xiaolai
Last active June 6, 2022 14:01
Show Gist options
  • Save xiaolai/7d0ab2b311ff80015c4a9bdc99059741 to your computer and use it in GitHub Desktop.
Save xiaolai/7d0ab2b311ff80015c4a9bdc99059741 to your computer and use it in GitHub Desktop.
My own library
  1. Download and pin books at https://read.amazon.com, and use epubor KCR converter to convert them into epubs.
  2. Download audio books at https://audible.com, with aax format.
  3. Obtain your activation bytes with the instruction of this post.
  4. Install ffmpeg with brew.
  5. Install audible-converter with npm. (File name will be extended automatically)
audible-converter "*.aax" -a <your-activation-bytes>
  1. Install atomicparsley with brew. (to add artwork to converted m4a files) Bash script to add artworks to m4a files:
for f in *.m4a
do
    atomicparsley "$f" --artwork "${f//m4a/png}"
done
find . -type f \! -name “*temp*” -delete
for f in *.m4a
do
    g=${f//-temp*./.}
    mv "$f" "$g"
done
  1. Install recoll on a remote vps(ubuntu). (aliyun problem:https://yq.aliyun.com/articles/392293)

  2. Install recoll-webui python3 mod, with this guide.

  3. Use rsync and crontab to sync local and remote server. (add local ~/.ssh/id_rsa.pub content to the server ~/.ssh/authorized_keys to use rsync in ctrontab.)

  4. modify /etc/hosts.

  5. add custom search to alfred.

Python ipynb for download aax from audible.com programatially:

from selenium import webdriver
import random
import time

URL = "https://audible.com"

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--window-size=1920,1080')
chromedriver_path = '/usr/local/bin/chromedriver'

driver = webdriver.Chrome(chromedriver_path, options=chrome_options)
driver.get(URL)
time.sleep(random.randint(2,5))

def login():
    driver.find_element_by_class_name("ui-it-sign-in-link ").click()
    time.sleep(random.randint(2,5))
    driver.find_element_by_id("ap_email").send_keys("<your-login-email-address>")
    time.sleep(random.randint(2,5))
    driver.find_element_by_id ("ap_password").send_keys("<your-password>")
    time.sleep(random.randint(2,5))
    driver.find_element_by_id("signInSubmit").click()

login()

time.sleep(random.randint(2,5))

driver.find_element_by_link_text("Library").click()

time.sleep(random.randint(2,5))

links = driver.find_elements_by_css_selector("a.bc-button-text")

# how many books do you want download?

import wget

book = 1
for i in range(0, book):
    wget.download(links[i].get_attribute('href'))
    print(links[i].get_attribute('href'))
    
print('done')

driver.close()

Shell script I use to convert aax:

#! /bin/bash

mkdir ~/Public/temp
mv ~/Downloads/*.aax ~/Public/temp
cd ~/Public/temp
echo $PWD
audible-converter "*.aax" -a <your-code-here>
for f in *.m4a
do
    atomicparsley "$f" --artwork "${f//m4a/png}"
done
echo "deleting files not containing 'temp'..."
find . -type f \! -name "*temp*" -delete
echo "renaming files..."
for f in *.m4a
do
    g=${f//-temp*./.}
    mv "$f" "$g"
done
ls -a
echo "move *.m4a to ~/Dropbox/amazon-kindle-audible-files/m4a/ ..."
mv *.m4a ~/Dropbox/amazon-kindle-audible-files/m4a/
cd ~/
rm -rf ~/Public/temp
echo "Done!"
@JKamsker
Copy link

Saving time with finding ur code: https://audible-tools.github.io/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment