From 12cb080141b8bc28dd3e84dec4023db40104dee3 Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Wed, 22 Mar 2023 20:28:58 -0400 Subject: [PATCH] mrss.sh: only prefer enclosure link for audio this means that 'mrss link' for podcasts will return the audio link, but for images it will return the normal article link. --- contrib/mrss.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/contrib/mrss.sh b/contrib/mrss.sh index 59e38a7..4f27003 100755 --- a/contrib/mrss.sh +++ b/contrib/mrss.sh @@ -78,13 +78,29 @@ sub_purge() { } list_link() { - for art in "$@"; do - cat "$art" | jq -r '.enclosure.link // .link' + while read -r art; do + LINK="$(cat "$art" | jq -r '.link // ""')" + ENCLOSURE="$(cat "$art" | jq -r '.enclosure.link // ""')" + ENCLOSURE_TYPE="$(cat "$art" | jq -r '.enclosure.type // ""')" + + if [ -z "$ENCLOSURE" ]; then + printf "%s\n" "$LINK" + else + if printf "%s" "$ENCLOSURE_TYPE" | grep --quiet "^audio/.*" ; then + # this is a podcast so use enclosure instead of link + printf "%s\n" "$ENCLOSURE" + else + # some people put random images in enclosure + printf "%s\n" "$LINK" + fi + fi done } sub_link() { - cat "$@" | jq -r '.enclosure.link // .link' + for art in "$@"; do + printf "%s\n" "$art" + done | list_link } list_read() {