From 732c02ed53553d78f81e0596b0551d05ad13c30b Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 16 Aug 2015 22:52:43 +0200 Subject: initi youtube-tools --- bin/ogg-maker | 14 ++++++++++++++ bin/yout2mp3 | 2 ++ bin/yout2ogg | 24 ++++++++++++++++++++++++ bin/youtplaylist | 2 ++ 4 files changed, 42 insertions(+) create mode 100755 bin/ogg-maker create mode 100755 bin/yout2mp3 create mode 100755 bin/yout2ogg create mode 100755 bin/youtplaylist (limited to 'bin') diff --git a/bin/ogg-maker b/bin/ogg-maker new file mode 100755 index 0000000..4528df2 --- /dev/null +++ b/bin/ogg-maker @@ -0,0 +1,14 @@ +#!/bin/sh +filename="$1" +outname=$(echo $1 | sed 's/^\(.*\)\..*/\1/').ogg +if [ "$filename" == "$outname" ]; then + ffmpeg -i $filename tmp_$filename + sox --norm=3 $filename tmp_$filename silence 1 0.1 1% reverse silence 1 0.1 1% reverse rate 44100 + vorbisgain ${filename}tmp + mv tmp_$filename $filename +else + ffmpeg -i $filename $outname + sox --norm=-3 $filename $outname silence 1 0.1 1% reverse silence 1 0.1 1% reverse rate 44100 + vorbisgain $outname + rm $filename +fi diff --git a/bin/yout2mp3 b/bin/yout2mp3 new file mode 100755 index 0000000..64e1bb1 --- /dev/null +++ b/bin/yout2mp3 @@ -0,0 +1,2 @@ +#!/bin/sh +youtube-dl -i -o "%(title)s.%(ext)s" --restrict-filenames -x --audio-format mp3 "$@" diff --git a/bin/yout2ogg b/bin/yout2ogg new file mode 100755 index 0000000..b6ab9c9 --- /dev/null +++ b/bin/yout2ogg @@ -0,0 +1,24 @@ +#! /bin/sh +set -euf +target_folder="./music" + +uri=$1 +id=$(echo "$uri" | sed -n 's@^https\?://www\.youtube\.com/watch?v=@@p' | sed 's/#.*$//') +script=$(readlink -f "$0") +basedir=$(dirname $script) + +mkdir -p $target_folder + +if ! echo "$id" | grep -q .; then + echo "bad uri: $uri" >&2 + exit 23 +fi + +cd $target_folder + +if file=$(ls | grep "[-]$id\\.ogg\$"); then + echo "already done: $file in $target_folder" >&2 + exit +fi + +youtube-dl -i -o "%(title)s-%(id)s.%(ext)s" --restrict-filenames -x "$uri" --add-metadata --exec "$basedir/ogg-maker {}" diff --git a/bin/youtplaylist b/bin/youtplaylist new file mode 100755 index 0000000..c2468a0 --- /dev/null +++ b/bin/youtplaylist @@ -0,0 +1,2 @@ +#!/bin/sh +youtube-dl -i -o "http://www.youtube.com/watch?v=%(id)s#%(title)s" --restrict-filenames --get-filename $1 -- cgit v1.2.3