more changes

This commit is contained in:
Balakrishnan Balasubramanian 2022-08-04 17:52:12 -04:00
parent 2bb8fa675a
commit 469196c0fa

54
down.sh
View File

@ -4,28 +4,52 @@
# yq # yq
# curl # curl
echo "Running from: $PWD" mkdir -p ./{cache,state,Podcasts}
# rm -rf ./cache/*
yqf() YQ=~/bin/yq
{
~/bin/yq "$1" config.yaml yqf() {
$YQ "$1" config.yaml
} }
export ALL_PROXY="socks5h://127.0.0.1:9050" export ALL_PROXY="socks5h://127.0.0.1:9050"
entries=".entries" download() {
local e name url limit mp3url
e=$1
name=$(yqf "${e}.name")
url=$(yqf "${e}.url")
# limit=$(yqf "${e}.limit")
limit=2
filter=$(yqf "${e}.filter // true")
for id in $(yqf "$entries | keys | .[]") local rss_path="cache/${name}.rss"
local downloads_path="state/${name}.downloads"
false && curl -L -o "$rss_path" "$url"
#limit=$limit $YQ -p xml '.rss.channel.item[] | keys | .[] | select(. < env(limit)) | .[]' "$rss_path"
items=".rss.channel.item"
ids=$($YQ -p xml "$items | .[] | select($filter) | path | .[-1]" "$rss_path" |
head -n "$limit")
for id in $ids
do
echo "id is $id"
#$YQ -p xml "$items.$id | (.title |= .[0]) | .title" "$rss_path"
mp3url=$($YQ -p xml "$items.$id | .enclosure.+url" "$rss_path")
grep -q --fixed-strings "$mp3url" "$downloads_path" && continue
echo "Downloading: $mp3url"
echo "$mp3url" >> "$downloads_path"
done
}
entries=".entries"
for id in $(yqf "$entries | .[] | path | .[-1]")
do do
entry="${entries}.$id"
name=$(yqf "${entry}.name")
url=$(yqf "${entry}.url")
limit=$(yqf "${entry}.limit")
echo "============================ start ============================" echo "============================ start ============================"
curl -L -o "cache/${name}.rss" "$url" download "${entries}.$id"
# download "$name" "${name}.rss" & # exit
echo "$name"
echo "$url"
echo "$limit"
echo "============================ done ============================" echo "============================ done ============================"
done done