Skip to content

Instantly share code, notes, and snippets.

@tatze
Created October 1, 2019 20:42
Show Gist options
  • Save tatze/b9136bb29666522ba1984956e22e5e36 to your computer and use it in GitHub Desktop.
Save tatze/b9136bb29666522ba1984956e22e5e36 to your computer and use it in GitHub Desktop.
#!/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