more changes
This commit is contained in:
parent
2bb8fa675a
commit
469196c0fa
54
down.sh
54
down.sh
@ -4,28 +4,52 @@
|
||||
# yq
|
||||
# curl
|
||||
|
||||
echo "Running from: $PWD"
|
||||
mkdir -p ./{cache,state,Podcasts}
|
||||
# rm -rf ./cache/*
|
||||
|
||||
yqf()
|
||||
{
|
||||
~/bin/yq "$1" config.yaml
|
||||
YQ=~/bin/yq
|
||||
|
||||
yqf() {
|
||||
$YQ "$1" config.yaml
|
||||
}
|
||||
|
||||
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
|
||||
entry="${entries}.$id"
|
||||
name=$(yqf "${entry}.name")
|
||||
url=$(yqf "${entry}.url")
|
||||
limit=$(yqf "${entry}.limit")
|
||||
echo "============================ start ============================"
|
||||
curl -L -o "cache/${name}.rss" "$url"
|
||||
# download "$name" "${name}.rss" &
|
||||
echo "$name"
|
||||
echo "$url"
|
||||
echo "$limit"
|
||||
download "${entries}.$id"
|
||||
# exit
|
||||
echo "============================ done ============================"
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user