commit 21cd9993a97ff5ec30d3383e15f8dd1107c60217 parent 605681cbf3799a4a2b0c7250c980020e437746cb Author: Alex Balgavy <a.balgavy@gmail.com> Date: Sat, 7 Dec 2019 20:19:34 -0500 script: download videos from JSON file Former-commit-id: bbd3d52d05c8c98b373a302acc336dfcc75d1b02 Diffstat:
A | scripts/video-json-download.sh | | | 24 | ++++++++++++++++++++++++ |
1 file changed, 24 insertions(+), 0 deletions(-)
diff --git a/scripts/video-json-download.sh b/scripts/video-json-download.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +die() { + echo "$1" >&2 + exit 1 +} + +[ $# -ge 1 ] || die "Argument required" +nvideos=$(cat "$1" | jq length) + +for i in `seq 0 $nvideos`; do + name="$(cat "$1" | jq "keys[$i]")" + url="$(cat "$1" | jq ."$name")" + echo "$name: $url" + + youtube-dl -o "$(echo $name | tr -d '"' | sed 's/.mp4//').mp4" "$(echo $url | tr -d '"')" &>/dev/null & + echo "Downloading $name" + + if [ $(expr $i % 4) -eq 0 ]; then + echo "Waiting..." + wait + fi +done + +for f in *.mp4; do ffmpeg -i "$f" -acodec libmp3lame -vn -b:a 320k "${f%.mp4}.mp3"; done