Skip to content

Instantly share code, notes, and snippets.

@hbend1li
Last active April 13, 2020 18:03
Show Gist options
  • Save hbend1li/da5fcd099b657f545e9b513fa55d5149 to your computer and use it in GitHub Desktop.
Save hbend1li/da5fcd099b657f545e9b513fa55d5149 to your computer and use it in GitHub Desktop.
Download from soundcloud by using youtube-dl, and generate .m3u playlist file
#!/bin/bash
if [ "$1" == "upgrade" ]; then
sudo pip3 install --upgrade youtube-dl
elif [ "$1" ]; then
youtube-dl -c -f best --embed-thumbnail --add-metadata -o '%(playlist)s/%(title)s-%(id)s.%(ext)s' $1
PLAYLIST=$(youtube-dl --get-filename -o "%(uploader)s.m3u" $1)
echo "#EXTM3U" > "$PLAYLIST"
youtube-dl --get-filename -o "#EXTINF:-1,%(title)s\r\n%(playlist)s/%(title)s-%(id)s.%(ext)s" $1 >> "$PLAYLIST"
sed -i -e 's/\\r\\n/\r\n/g' "$PLAYLIST"
else
echo "soundcloud.sh {URL}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment