Last active
July 16, 2021 05:28
-
-
Save albertyw/0eb7564341334e85e7d9ebf816a66c0a to your computer and use it in GitHub Desktop.
Download and convert youtube playlists to MP3
This file contains hidden or 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 | |
| # This script converts an mp4 into an mp3 | |
| # It works by running ffmpeg in a docker container | |
| set -euo pipefail | |
| IFS=$'\n' | |
| convert () { | |
| input="$1" | |
| output="$input.mp3" | |
| docker run -v "$(pwd):$(pwd)" -w "$(pwd)" jrottenberg/ffmpeg:3.4-scratch \ | |
| -stats \ | |
| -i "./$input" -vn \ | |
| -acodec libmp3lame -ac 2 -qscale:a 4 -ar 48000 \ | |
| "./$output" | |
| } | |
| if [ -z "${1-}" ]; then | |
| for f in $(find . -type f -name "*.mp4"); do | |
| convert "$f" | |
| done | |
| else | |
| convert "$1" | |
| fi |
This file contains hidden or 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 | |
| # Download a youtube playlist | |
| set -euo pipefail | |
| IFS=$'\n\t' | |
| url="$1" | |
| wget https://yt-dl.org/downloads/2021.06.06/youtube-dl-2021.06.06.tar.gz | |
| tar xvf youtube-dl* | |
| screen python3 youtube-dl/youtube-dl "$url" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment