Skip to content

Instantly share code, notes, and snippets.

@laventura
Forked from yismailuofa/get-books.sh
Created October 1, 2024 19:04
Show Gist options
  • Save laventura/11dc1b017aa1a1a8cd166dccdec94f8b to your computer and use it in GitHub Desktop.
Save laventura/11dc1b017aa1a1a8cd166dccdec94f8b to your computer and use it in GitHub Desktop.
Get URL Schemes For Your Apple Books on MacOS
#!/bin/bash
# Path to the BKLibrary file
BKLIBRARY_PATH=~/Library/Containers/com.apple.iBooksX/Data/Documents/BKLibrary
# Check if BKLibrary file exists
if [ ! -f "$BKLIBRARY_PATH/BKLibrary-"*".sqlite" ]; then
echo "BKLibrary file not found. Please make sure Books app is installed and has been opened at least once."
exit 1
fi
# Get the full path of the BKLibrary file
BKLIBRARY_FILE=$(ls "$BKLIBRARY_PATH"/BKLibrary-*.sqlite)
# Execute sqlite command to fetch book titles and asset IDs
sqlite3 "$BKLIBRARY_FILE" <<EOF
select ztitle, 'ibooks://assetid/' || zassetid from zbklibraryasset;
EOF
@laventura
Copy link
Author

TODO: Use SimonwW's datasette plugins to do something useful with the sqlite DB

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