summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorlassulus <lass@aidsballs.de>2015-08-16 22:52:43 +0200
committerlassulus <lass@aidsballs.de>2015-08-16 22:52:43 +0200
commit732c02ed53553d78f81e0596b0551d05ad13c30b (patch)
treeceafa0cadceb700fc9b484df06d9dd2025ed429e /bin
initi youtube-tools
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ogg-maker14
-rwxr-xr-xbin/yout2mp32
-rwxr-xr-xbin/yout2ogg24
-rwxr-xr-xbin/youtplaylist2
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 "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