more changes
This commit is contained in:
parent
2bb8fa675a
commit
469196c0fa
58
down.sh
58
down.sh
@ -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"
|
echo "============================ start ============================"
|
||||||
name=$(yqf "${entry}.name")
|
download "${entries}.$id"
|
||||||
url=$(yqf "${entry}.url")
|
# exit
|
||||||
limit=$(yqf "${entry}.limit")
|
echo "============================ done ============================"
|
||||||
echo "============================ start ============================"
|
|
||||||
curl -L -o "cache/${name}.rss" "$url"
|
|
||||||
# download "$name" "${name}.rss" &
|
|
||||||
echo "$name"
|
|
||||||
echo "$url"
|
|
||||||
echo "$limit"
|
|
||||||
echo "============================ done ============================"
|
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user