scripts

misc scripts and tools
git clone git://git.2f30.org/scripts
Log | Files | Refs

commit 014eb10ffbe2d4ae9d1969554b2268026274d838
parent a072fe791ea61556f1a047e704a9ca600563734f
Author: sin <sin@2f30.org>
Date:   Mon,  4 Nov 2013 13:50:09 +0000

Simple script to download videos from youtube and convert them to
mp3 using ffmpeg.

Diffstat:
Aytget | 34++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+), 0 deletions(-)

diff --git a/ytget b/ytget @@ -0,0 +1,34 @@ +#!/bin/sh +# +# Simple script to download videos from youtube and convert +# them to mp3 using ffmpeg. + +out=$HOME/yt + +if test -z "$1"; then + echo "usage: $(basename $0) yt-url..." 1>&2 + exit 1 +fi + +# Check for dependencies +which youtube-dl >/dev/null || \ + { echo "I can't find youtube-dl, please install it" 1>&2; exit 1; } +which ffmpeg >/dev/null || \ + { echo "I can't find ffmpeg, please install it" 1>&2; exit 1; } + +mkdir -p "$out" + +trap 'rm -f "/tmp/$infile.part" "$out/$outfile"; exit 1' 2 + +function convert { + in="$1" + out="$2" + ffmpeg -i "$in" "$out" +} + +for i in "$@"; do + infile=$(youtube-dl --get-filename "$i") + outfile="${infile%.*}.mp3" + youtube-dl "$i" -o "/tmp/$infile" + convert "/tmp/$infile" "$out/$outfile" +done