forked from andresgottlieb/rhlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.sh
executable file
·32 lines (29 loc) · 907 Bytes
/
process.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
if [ -z "$1" ]; then
dir=$(pwd)
else
dir="$1"
fi
if [ ! -d "${dir}/json" ]; then
echo "Missing json subdirectory in ${dir}. Exiting …" 1>&2
exit 1
fi
for f in "${dir}/json/"*.json; do
filename="${f##*/}"
album="${filename%.json}"
videos=$(jq ".video[0] | length" $f)
while [ $videos -gt 0 ]
do
videos=$[$videos-1]
url=$(jq ".video[0][$videos].url" $f --raw-output)
platform=$(jq ".video[0][$videos].platform" $f --raw-output)
echo "Hey $url ($platform)"
if [ $platform = "vimeo" ]
then
youtube-dl "https://player.vimeo.com/video/$url" --referer "https://radiohead.com" -f best -o "./video/$album/%(title)s.%(ext)s" --verbose
elif [ $platform = "youtube" ]
then
youtube-dl "https://www.youtube.com/watch?v=$url" --referer "https://radiohead.com" -f best -o "./video/$album/%(title)s.%(ext)s" --verbose
fi
done
done