Created
October 1, 2019 20:42
-
-
Save tatze/b9136bb29666522ba1984956e22e5e36 to your computer and use it in GitHub Desktop.
This file contains 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 | |
set -Eeuo pipefail | |
# | |
# 20191001 | tatze | |
# ------------------------------------------ | |
# programs needed: | |
# - ffmpeg | |
# - youtube-dl | |
# ------------------------------------------ | |
# ------------------------------------------ | |
# terminal output: bold or normal? | |
bold=$(tput bold) | |
normal=$(tput sgr0) | |
# arguments needed | |
if [ $# -lt 2 ] | |
then | |
printf "Not enough arguments supplied, URL and filename needed\n${bold}Usage: ${normal}downloadStream <URL> <filename>" | |
exit 1 | |
else | |
if [ -f "$2" ] | |
then | |
printf "file already exists, aborting." | |
exit 1 | |
else | |
printf "${bold}getting manifest...\n" | |
fcode=`youtube-dl --list-formats $1 | grep "(best)"` | |
printf "using ${normal}$fcode\n" | |
codenr=${fcode%% *} | |
ffmpeg -i $(youtube-dl -f $codenr -g $1) -c copy "$2" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment