diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/ogg-maker | 14 | ||||
-rwxr-xr-x | bin/yout2mp3 | 2 | ||||
-rwxr-xr-x | bin/yout2ogg | 24 | ||||
-rwxr-xr-x | bin/youtplaylist | 2 |
4 files changed, 42 insertions, 0 deletions
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 "[31mbad uri: $uri[m" >&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 |