Skip to content

Instantly share code, notes, and snippets.

@mhay10
Last active March 30, 2023 16:35
Show Gist options
  • Select an option

  • Save mhay10/9e905f016b1ad3e119f1a613089773bb to your computer and use it in GitHub Desktop.

Select an option

Save mhay10/9e905f016b1ad3e119f1a613089773bb to your computer and use it in GitHub Desktop.
#!/bin/bash
function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
if [ "$1" = "" ]; then
echo "Usage: $(basename $0) <audiobook url> <output dir - optional>"
exit 1
fi
book_url=$1
[ "$2" != "" ] && output_dir=$2 || output_dir="."
book_res=$(curl -s $book_url)
audio_urls=($(echo $book_res | grep -Po '(?<=><a href=")https:\/\/ipaudio\.club\/.*?(?=">)'))
count=1
for url in ${audio_urls[@]}; do
filename="$(urldecode $(echo $url | perl -n -e ' /(?<=uploads)(\/.*?\/)(.*)(?=\/)/ && print $2'))_$count.mp3"
mkdir -p $output_dir &> /dev/null
echo "Now downloading file $count of ${#audio_urls[@]}"
curl -s $url -o "$output_dir/$filename"
((count++))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment