Use JSON for configuration

This commit is contained in:
Michael De Roover 2023-04-19 21:58:40 +02:00
parent 931b8f2db8
commit 8fdd1ef3d0
Signed by: vim
GPG Key ID: 075496E232CE04CB

View File

@ -9,23 +9,29 @@ help(){
exit 1
}
[[ -z "$1" || "$1" == "-h" || "$1" == "--help" ]] && help
[[ "$1" == "-h" || "$1" == "--help" ]] && help
saveifs=$IFS
IFS=$'\n'
directory=$1
iterations=$(jq -r ".subscriptions | length" < subscriptions.json)
[ ! -d "$directory" ] && mkdir -p "$directory"
[ ! -d "PSP/$directory" ] && mkdir -p "PSP/$directory"
youtube-dl "$2" -f 18 -o "$directory/%(title)s.%(ext)s"
files=($(ls "$directory"))
for file in ${files[*]}
for (( iteration=0; iteration<$iterations; iteration++ ))
do
[ ! -f "PSP/$directory/$file" ] && \
f_convert-psp "$directory"/"$file"
directory=$(jq -r ".subscriptions[$iteration].name" < subscriptions.json)
channelURL=$(jq -r ".subscriptions[$iteration].link" < subscriptions.json)
[ ! -d "$directory" ] && mkdir -p "$directory"
[ ! -d "PSP/$directory" ] && mkdir -p "PSP/$directory"
youtube-dl "$channelURL" -f 18 -o "$directory/%(title)s.%(ext)s"
files=($(ls "$directory"))
for file in ${files[*]}
do
[ ! -f "PSP/$directory/$file" ] && \
f_convert-psp "$directory"/"$file"
done
done
IFS=$saveifs