scripts

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

commit 02531b8299096bdbcd9e0a26e043023e764f4b28
parent 514154a863ee2c22b7065987fd16419cacab7d39
Author: sin <sin@2f30.org>
Date:   Mon,  4 Nov 2013 15:21:10 +0000

Rename ytget to ytfetch

Diffstat:
ytfetch | 38++++++++++++++++++++++++++++++++++++++
ytget | 38--------------------------------------
2 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/ytfetch b/ytfetch @@ -0,0 +1,38 @@ +#!/bin/sh +# +# Simple script to download songs from youtube and encode +# them to mp3 using ffmpeg. This script also handles playlists. + +out=$HOME/music/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" +scratch=$(mktemp -d) + +# Download all songs to the scratch space +for i in "$@"; do + youtube-dl -o "$scratch/%(title)s.%(ext)s" "$i" +done + +function encode { + in="$1" + out="$2" + ffmpeg -y -i "$in" "$out" +} + +# Encode all of them +cd $scratch +for i in *; do + outfile="${i%.*}.mp3" + encode "$i" "$outfile" +done diff --git a/ytget b/ytget @@ -1,38 +0,0 @@ -#!/bin/sh -# -# Simple script to download songs from youtube and encode -# them to mp3 using ffmpeg. This script also handles playlists. - -out=$HOME/music/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" -scratch=$(mktemp -d) - -# Download all songs to the scratch space -for i in "$@"; do - youtube-dl -o "$scratch/%(title)s.%(ext)s" "$i" -done - -function encode { - in="$1" - out="$2" - ffmpeg -y -i "$in" "$out" -} - -# Encode all of them -cd $scratch -for i in *; do - outfile="${i%.*}.mp3" - encode "$i" "$outfile" -done