Skip to content

Instantly share code, notes, and snippets.

@dashdanw
Created October 17, 2018 03:46
Show Gist options
  • Save dashdanw/32e74c22a9fa40e9067f2b730f4463cd to your computer and use it in GitHub Desktop.
Save dashdanw/32e74c22a9fa40e9067f2b730f4463cd to your computer and use it in GitHub Desktop.
#!/bin/bash
if [[ -z $(pip3 show scdl) ]]; then
sudo pip3 install scdl
fi
SCDL_TARGET="$1"
shift
SCDL_ADD_ARGS="$@"
SCDL_TARGET_DIR="$(pwd)/$SCDL_TARGET"
SCDL_PREFIX="scdl -l https://soundcloud.com/$SCDL_TARGET"
SCDL_SUFFIX="-c --addtofile"
echo -e "Downloading everything from $SCDL_TARGET to $SCDL_TARGET_DIR . . . . \n\n"
mkdir -p $SCDL_TARGET_DIR
#this is confusing, it's basically a dictionary of {type: flag, type2: flag2 . . . }
declare -A SCDL_FLAGS=( ["uploads"]="-t" ["favorites"]="-f" ["commented"]="-C" ["playlists"]="-p")
for SCDL_TYPE in "${!SCDL_FLAGS[@]}"; do
SCDL_FLAG=${SCDL_FLAGS[$SCDL_TYPE]}
SCDL_TARGET_TYPE_DIR=$SCDL_TARGET_DIR/$SCDL_TYPE
mkdir -p $SCDL_TARGET_TYPE_DIR
SCDL_CMD="$SCDL_PREFIX $SCDL_FLAG --path $SCDL_TARGET_TYPE_DIR $SCDL_SUFFIX $SCDL_ADD_ARGS"
echo "$SCDL_CMD"
eval $SCDL_CMD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment