summaryrefslogtreecommitdiffstats
path: root/bin/yout2mp3
diff options
context:
space:
mode:
authorlassulus <lass@aidsballs.de>2015-11-08 10:58:47 +0100
committerlassulus <lass@aidsballs.de>2015-11-08 10:58:47 +0100
commite29d40227ee37f6fd4b2a6d770bff90ff36727a9 (patch)
tree53c70543a12add3bbc83964107f1f766c946270c /bin/yout2mp3
parent379a72064c7995ca751a71568ff629cfb0270b20 (diff)
yout2mp3: load only new tracks
Diffstat (limited to 'bin/yout2mp3')
-rwxr-xr-xbin/yout2mp326
1 files changed, 24 insertions, 2 deletions
diff --git a/bin/yout2mp3 b/bin/yout2mp3
index 64e1bb1..74ed177 100755
--- a/bin/yout2mp3
+++ b/bin/yout2mp3
@@ -1,2 +1,24 @@
-#!/bin/sh
-youtube-dl -i -o "%(title)s.%(ext)s" --restrict-filenames -x --audio-format mp3 "$@"
+#! /bin/sh
+set -euf
+target_folder=${target-./}
+
+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 --audio-format mp3