Skip to content

Instantly share code, notes, and snippets.

@crueber
Last active November 20, 2024 14:14
Show Gist options
  • Save crueber/45b385d04fcbf0331fab019e4800c0c9 to your computer and use it in GitHub Desktop.
Save crueber/45b385d04fcbf0331fab019e4800c0c9 to your computer and use it in GitHub Desktop.
Pull latest purchases from Audible and convert to M4B using AAXtoMP3
#!/bin/bash
# Get today's date in YYYY-MM-DD format
TODAY=$(date +%Y-%m-%d)
# Get yesterday's date in YYYY-MM-DD format
YESTERDAY=$(date -v-1d +%Y-%m-%d)
# Check if .latestpull file exists, if not create it and set the initial value to $YESTERDAY
if [ ! -f .latestpull ]; then
echo "$YESTERDAY" > .latestpull
fi
# Read the last run date from .latestpull file
LAST_RUN=$(cat .latestpull)
# Run audible download command using the last run and today's dates
echo "Pulling Audible Purchases."
echo "Last Run: $LAST_RUN"
echo "Today: $TODAY"
audible download --start-date "$LAST_RUN" --end-date "$TODAY" --aax-fallback --all --cover --cover-size 1215 --chapter --ignore-errors
echo "Pull complete."
# Convert from Audible Proprietary Format to M4B
bash AAXtoMP3/AAXtoMP3 -e:m4b -C ./done ./*aax
bash AAXtoMP3/AAXtoMP3 -e:m4b -C ./done ./*aaxc
# Update the .latestpull file with today's date for next script run
echo "$TODAY" > .latestpull
# Move files to done folder
mv *voucher ./done/
mv *json ./done/
mv *jpg ./done/
@crueber
Copy link
Author

crueber commented Nov 20, 2024

Ensure that:

  1. You have AAXtoMP3 cloned in that directory
  2. The done folder exists
  3. You are logged in using the audible-cli tools.

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