some cleanup

This commit is contained in:
Balakrishnan Balasubramanian 2023-01-09 20:46:08 -05:00
parent 013d5ed60d
commit 70d3372bf3
2 changed files with 6 additions and 13 deletions

View File

@ -12,12 +12,6 @@ yqf() {
$YQ "$1" config.yaml
}
dryrun() {
false
}
dryrun || rm -rf ./cache/*
make_fname() {
local name ftype title
ftype=$1; name=$2; title=$3
@ -47,7 +41,7 @@ download() {
local rss_path="cache/${name}.rss"
local downloads_path="state/${name}.downloads"
dryrun || curl -s -L -o "$rss_path" "$url"
curl -s -L -o "$rss_path" "$url"
items=".rss.channel.item"
ids=$($YQ -p xml "$items | .[] | select($filter) | path | .[-1]" "$rss_path" |
@ -56,12 +50,10 @@ download() {
for id in $ids
do
title=$($YQ -p xml "$items.$id | (.title |= .[0]) | .title" "$rss_path")
mp3url=$($YQ -p xml "$items.$id | .enclosure.+url" "$rss_path")
mp3url=$($YQ -p xml "$items.$id | .enclosure.+@url" "$rss_path")
grep -qF "$mp3url" "$downloads_path" && continue
echo "Downloading: $title - $mp3url"
# mp3path=$(mktemp -p cache "${name}.XXXXXX.mp3")
dryrun && continue
cd cache || return
read -ra title_options < <(make_fname "$ftype" "$name" "$title")
fname=$(curl -s -w "%{filename_effective}" -f -L "${title_options[@]}" "$mp3url")

View File

@ -2,6 +2,7 @@ $schema: http://json-schema.org/draft/2020-12/schema
type: object
properties:
entries:
description: Array of feeds to download
type: array
items:
type: object
@ -15,20 +16,20 @@ properties:
limit:
type: integer
description: Number of entries to download
default: 1
filename_type:
type: string
description: Decides how the files are named
default: default
enum:
- default
- title
- date
filter:
type: string
default: "true"
description: yq filter expression
foobar: hello world
required:
- filename_type
- limit
- name
- url
required: