diff options
author | lassulus <lass@aidsballs.de> | 2015-08-16 22:52:43 +0200 |
---|---|---|
committer | lassulus <lass@aidsballs.de> | 2015-08-16 22:52:43 +0200 |
commit | 732c02ed53553d78f81e0596b0551d05ad13c30b (patch) | |
tree | ceafa0cadceb700fc9b484df06d9dd2025ed429e /bin/yout2ogg |
initi youtube-tools
Diffstat (limited to 'bin/yout2ogg')
-rwxr-xr-x | bin/yout2ogg | 24 |
1 files changed, 24 insertions, 0 deletions
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 {}" |