Skip to content

Instantly share code, notes, and snippets.

@TrevorBasinger
Created July 28, 2015 19:24
Show Gist options
  • Save TrevorBasinger/11f91a751eba9eb451e0 to your computer and use it in GitHub Desktop.
Save TrevorBasinger/11f91a751eba9eb451e0 to your computer and use it in GitHub Desktop.
#!/bin/bash
function detectBin {
which $1 > /dev/null
RET=$?
if [ $RET = "1" ]; then
echo "You need to install $1"
exit -1
fi
}
detectBin youtube-dl
detectBin ffmpeg
detectBin aws
TMP=/tmp/`date +%s`
###
# Usage:
# ythelper outfile.mp3 youtubeurl startingtime secondsafterstartingtime
#
# Example
# ythelper wtf.mp3 https://youtu.be/oXYZttxunPw 00:00:08.0 2.0
##
youtube-dl -x --audio-format mp3 -o "$TMP.%(ext)s" $2 >> /dev/null && \
ffmpeg -ss $3 -t $4 -i "$TMP.mp3" $1 >> /dev/null && \
aws s3 cp $1 s3://flobot-sounds/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment