diff --git a/pdown.sh b/pdown.sh index 30f0f7e..fa4f436 100755 --- a/pdown.sh +++ b/pdown.sh @@ -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") diff --git a/schema.yaml b/schema.yaml index 1cfecda..c1f76a5 100644 --- a/schema.yaml +++ b/schema.yaml @@ -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: