Skip to content

Instantly share code, notes, and snippets.

@McFlat
Last active November 19, 2020 05:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McFlat/9cbde691c53e2192613a48967d4ec666 to your computer and use it in GitHub Desktop.
Save McFlat/9cbde691c53e2192613a48967d4ec666 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# this program should work only on linux and mac not windows
# this program download files from server one at a time instead of many in order to avoid errors due to rate limits
# 1. download/install mini client program first called mc
# https://min.io/download#/linux
# https://min.io/download#/macos
# 2. configure the server to download videos from
# mc config host add download-troo https://data.troo.tube:443 download 123-Jesus-Christ-Lives-321
# 3. find a directory on the server to download all the videos from website or with mc ls command
# 4. mc ls
# 5. download all "Karen B" videos into the directory where you put this program
# all files videos and everything else
# ./getit.sh "Karen B" "all"
# videos only
# ./getit.sh "Karen B" "videos"
# other files not videos
# ./getit.sh "Karen B" "other"
trap kill_it TERM # 15 - Termination signal
trap kill_it PIPE # 13 - Broken pipe: write to pipe with no
trap kill_it SEGV # 11 - Invalid memory reference
trap kill_it KILL # 9 - Kill signal
trap kill_it FPE # 8 - Floating point exception
trap kill_it ABRT # 6 - Abort signal from abort(3)
trap kill_it ILL # 4 - Illegal Instruction
trap kill_it QUIT # 3 - Quit from keyboard
trap kill_it INT # 2 - Interrupt from keyboard
trap kill_it HUP # 1 - Hangup detected on controlling terminal or death of controlling process
KILLED=false
function kill_it() {
echo "Killed $@";
KILLED=true;
exit 1;
}
DIR="$1"
KIND="${2:-"all"}"
SERVER="download-troo"
[ ! -d "$DIR" ] && mkdir "$DIR" # make directory where things are placed if not exists yet
IFS=$(echo -en "\n\b");
for i in $(mc ls $SERVER/videos/"$DIR" --no-color | awk '{$1=$2=$3=$4=""; print $0}' | sed -e 's/^ *//'); do
if [ $KILLED == false ]; then
if [ "$KIND" == "all" ] || [ "$KIND" == "videos" ] || [ "$KIND" == "other" ]; then
if [ "$KIND" == "all" ] || [ "$KIND" == "videos" ]; then
if [ "$KIND" == "all" ] || [[ "$i" == *".mp4" ]] || [[ "$i" == *".webm" ]]; then
mc cp $SERVER/videos/"$DIR"/"$i" "$DIR";
fi
fi
if [ "$KIND" == "all" ] || [ "$KIND" == "other" ]; then
if [ "$KIND" == "all" ] || [[ "$i" != *".mp4" ]] && [[ "$i" != *".webm" ]]; then
mc cp $SERVER/videos/"$DIR"/"$i" "$DIR";
fi
fi
fi
fi
done
#mc mirror $SERVER/videos/"$DIR" "$DIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment