Last active
October 14, 2021 18:18
-
-
Save yspreen/57bc93129c7691cf73dbfd866d147dc4 to your computer and use it in GitHub Desktop.
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 | |
## Use as ./convert_all.sh [DIRECTORY] | |
## | |
## i.e. ./convert_all.sh ~/Downloads | |
download_file() { | |
bash AAXtoMP3 --aac -c -e:m4b -t "./out" "$1" | |
} | |
main() { | |
pwd="$(pwd)" | |
script="$1" | |
source="$2" | |
cd "$source" | |
source="$(pwd)" | |
cd "$pwd" | |
cd "$(dirname "$script")" | |
which gfind 2>&1 > /dev/null || brew install findutils | |
which mediainfo 2>&1 > /dev/null || brew install mediainfo | |
if ! [ -f .authcode ] | |
then | |
echo "Place auth bytes into file .authcode" | |
return | |
fi | |
[ -d out ] || mkdir out | |
find "$source" -type f | grep -E '\.aax$' | while read f | |
do | |
download_file "$f" && \ | |
rm "$f" | |
done | |
find ./out -type f | grep -E '(Store|txt|jpg)$' | while read f | |
do | |
rm "$f" | |
done | |
} | |
main "$0" "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment