From e4ffce9a69395f628efb838f8f4c83d16f3ea751 Mon Sep 17 00:00:00 2001 From: hazardchem Date: Fri, 20 Oct 2023 12:33:34 +1000 Subject: [PATCH] sxmo_rss.sh: Allow up to 2 http requests instead of only handling 1st This changes to sxmo_rss.sh allows up to 2 http requests to be handled as some rss feeds provide either a link, or a link and enclosure, an example of this is PostmarketOS Podcast, with a link to the website and a link to the content in the same file. When the script detects more than one it breaks them into: Link {1st http address} Enclosure {2nd http address} Otherwise everything happens as per the script originally. This change line up with how sfeed_curses presents the links. Signed-off-by: hazardchem Signed-off-by: Willow Barraco --- scripts/appscripts/sxmo_rss.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/appscripts/sxmo_rss.sh b/scripts/appscripts/sxmo_rss.sh index c8ac7f3..eb6797b 100755 --- a/scripts/appscripts/sxmo_rss.sh +++ b/scripts/appscripts/sxmo_rss.sh @@ -46,7 +46,7 @@ prep_temp_folder_with_items() { list_items() { cd "$FOLDER" || die "Couldn't cd to $FOLDER" printf %b "Close Menu\nChange Timespan\n" - gawk -F'\t' '{print $1 " " substr(FILENAME, 3) " | " $2 ": " $3}' ./* |\ + gawk -F'\t' '{print $1 " " substr(FILENAME, 3) " | " $2 ": " $3 " " $8}' ./* |\ grep -E '^[0-9]{5}' |\ sort -nk1 |\ sort -r |\ @@ -113,8 +113,21 @@ rssreadmenu() { DMENUIDX=1 ;; *) - URL="$(echo "$PICKED" | awk -F " " '{print $NF}')" - sxmo_urlhandler.sh "$URL" + # Check for one http or 2, as there can be a link and enclosure + if [ "$(echo "$PICKED" | awk -F "http" '{print NF-1}')" = "1" ]; then + URL="$(echo "$PICKED" | awk -F " " '{print $NF}')" + sxmo_urlhandler.sh "$URL" + else + URL="$(echo "$PICKED" | grep "http" | awk -F ' ' '{print "Link " $(NF-1) "\nEnclosure " $NF}' | awk '($0){print} END{print "Close Menu"}' | sxmo_dmenu.sh)" + case "$URL" in + "Close Menu") return 0;; + *) + PLAY="$(echo "$URL" | awk -F " " '{print $NF}')" + sxmo_urlhandler.sh "$PLAY" + ;; + esac + fi + ;; esac done }