From 128198e0b509c9e6519870c24e60abbb33e57b71 Mon Sep 17 00:00:00 2001 From: randomuser Date: Mon, 18 Jul 2022 22:38:47 -0500 Subject: [PATCH] small changes --- Makefile | 1 - man/trss.1 | 2 -- sh/trss | 29 +++++++++++++++++++++++------ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index b4ce4b6..4ac0c1f 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,6 @@ sh: cp -f sh/trss-yt-id $(DESTDIR)$(PREFIX)/bin cp -f sh/disp $(DESTDIR)$(PREFIX)/bin cp -f sh/wallpaper $(DESTDIR)$(PREFIX)/bin - cp -f sh/yt $(DESTDIR)$(PREFIX)/bin cp -f sh/connect $(DESTDIR)$(PREFIX)/bin cp -f sh/nws $(DESTDIR)$(PREFIX)/bin cp -f sh/vol $(DESTDIR)$(PREFIX)/bin diff --git a/man/trss.1 b/man/trss.1 index 5decc38..575a9e5 100644 --- a/man/trss.1 +++ b/man/trss.1 @@ -21,8 +21,6 @@ open all feeds whose titles contain text as specified by an argument in 'lynx' this script is designed to allow one to obtain an rss feed for the uploads of a youtube channel. this command takes the homepage of the youtube channel in question as an argument and then returns the rss feed for that channel. .SH BUGS -- 'set' is a stub - - when in a feed, you can't cd to another directly, you must go to to the 'feed home' and then cd .SH DEPENDS diff --git a/sh/trss b/sh/trss index 6042cf8..dc07b04 100755 --- a/sh/trss +++ b/sh/trss @@ -23,7 +23,7 @@ sync_individual () { curl "$url" -so "$DATA/${1}.xml" # generate sfeed formatted file - printf "> creating sfeed compound feed file for feed %s\n" "$i" + printf "> creating sfeed compound feed file for feed %s\n" "$1" cat "$DATA/${1}.xml" | sfeed | cat - "$DATA/${1}.sfeed" | sort -u | sort -r -k 1 >> "$DATA/${1}.tmp.sfeed" mv "$DATA/${1}.tmp.sfeed" "${DATA}/${1}.sfeed" } @@ -53,8 +53,8 @@ cli_loop () { "sync"*) sync_handler $input ;; - "set"*) - set_handler $input + "open"*) + open_handler $input ;; esac } @@ -119,8 +119,25 @@ sync_handler () { fi } -set_handler () { - printf "stub, use +x or -x to disable/enable debug output\n" +open_handler() { + realargs="$(printf '%s\n' "$@" | tr '\n' ' ' | sed 's/^open //g;s/ $//g')" + [ -z "$MODE" ] && printf "couldn't find entry matching %s\n" "$realargs" + results="$(awk -F'\t' -v pat="$realargs" '$2 ~ pat { print $0 }' "$DATA/${MODE}.sfeed")" + + OLDIFS="$IFS" + IFS=" +" + + set -x + for i in $results; do + url="$(printf "%s" "$1" | awk -F'\t' '{ print $3 }')" + + echo "$url" + + fire "$url" & + done + set +x + IFS="$OLDIFS" } cat_handler () { @@ -138,8 +155,8 @@ cat_handler () { printf "%s\n" "$entry" | sed -e 's|\\n|\n|g' -e 's|\\t|\t|g' | lynx -stdin - done + IFS="$OLDIFS" } import_information