You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

30 lines
1.3 KiB

#!/bin/bash
# Should redo this in python
latest=$(</home/lhw/.config/gardenersworld)
job=$(curl -n -s https://scrapyd.hh.wellr.net/schedule.json -d project=gardenersworld -d spider=hdclump_wordpress_spider | jq -r ".jobid")
echo "[Queued] Job $job"
echo -n "[Waiting] "
until $(curl -n --output /dev/null --silent --head --fail https://scrapyd.hh.wellr.net/items/gardenersworld/hdclump_wordpress_spider/${job}.jl); do
printf '.'
sleep 2
done
sleep 5 # somehow have to wait here or it might not be ready
printf "\n"
ep_data=$(curl -n https://scrapyd.hh.wellr.net/items/gardenersworld/hdclump_wordpress_spider/${job}.jl | jq -r "select(.episode > $latest)")
if [[ $ep_data != "" ]]; then
episode=$(jq -n --argjson data "$ep_data" '$data.episode')
zepisode=$(printf "%02d" $episode)
season=54
url=$(jq -r -n --argjson data "$ep_data" '$data.links[0]')
file="Gardeners' World - s${season}e${zepisode} - Episode ${episode}.mp4"
echo "[Downloading] $url"
echo "[Downloading] Episode $episode"
echo "[Downloading] Season $season"
youtube-dl -i --external-downloader aria2c --external-downloader-args "-x 16 -s 16 -k 1M" "$url" --output "$file"
if [[ $? -eq 0 ]]; then
echo -n $episode > /home/lhw/.config/gardenersworld
mv "$file" "/media/raid/lhw/series/Gardeners' World/Season $season/"
fi
else
echo "[Finished] Most recent episode downloaded"
fi