#!/usr/bin/env sh
set -eou pipefail

# Old script to get json url for some reason? Don't know why I did this
# youtube-dl -j --flat-playlist -a - | \
# jq -r '.id' | \
# sed 's_^_https://youtu.be/_' | \
# wget-titles-from-urls >> titles.txt

test -f append.txt
if [[ $? -ne 0 ]]; then
    echo No append.txt found! Cannot append
    exit
fi

if [[ ! -s append.txt ]]; then
    echo append.txt is empty
    exit
fi

cat append.txt | wget-titles-from-urls >> titles.txt
cat append.txt | youtube-audio
> append.txt
