Last active
November 20, 2024 14:14
-
-
Save crueber/45b385d04fcbf0331fab019e4800c0c9 to your computer and use it in GitHub Desktop.
Pull latest purchases from Audible and convert to M4B using AAXtoMP3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ensure that:
done
folder exists