From a02b1170561dee26a3313410b12357b679c54a8c Mon Sep 17 00:00:00 2001 From: Oleksandr Miliukhin Date: Tue, 8 Jul 2025 14:46:25 +0300 Subject: [PATCH 1/2] Improve rssget: now able to parse YouTube @username urls, watch urls, and Telegram urls (feeds for Telegram are generated by rss-bridge). Make rssadd accept tags as "$2". --- .local/bin/rssadd | 2 +- .local/bin/rssget | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.local/bin/rssadd b/.local/bin/rssadd index 910fca31..6c532c74 100755 --- a/.local/bin/rssadd +++ b/.local/bin/rssadd @@ -14,5 +14,5 @@ RSSFILE="${XDG_CONFIG_HOME:-$HOME/.config}/newsboat/urls" if awk '{print $1}' "$RSSFILE" | grep "^$url$" >/dev/null; then notify-send "You already have this RSS feed." else - echo "$url" >> "$RSSFILE" && notify-send "RSS feed added." + echo "$url" "$2" >> "$RSSFILE" && notify-send "RSS feed added." fi diff --git a/.local/bin/rssget b/.local/bin/rssget index 5d470b4f..edadff61 100755 --- a/.local/bin/rssget +++ b/.local/bin/rssget @@ -43,11 +43,24 @@ getYoutubeRss() { feed=$(wget -q "$url" -O tmp_rssget_yt \ && sed -n 's|.*\("rssUrl":"[^"]*\).*|\1|; p' tmp_rssget_yt \ | grep rssUrl \ - | sed 's|"rssUrl":"||') ;; + | sed 's|"rssUrl":"||') + rm tmp_rssget_yt ;; + *"@"*) feed=$(wget -q "$url" -O tmp_rssget_yt \ + && sed -n 's|.*"\(https://www\.youtube\.com/feeds/videos\.xml?channel_id=[^"]*\)".*|\1|p' tmp_rssget_yt) + rm tmp_rssget_yt ;; + *"watch"*) channel_id=$(wget -q "$url" -O tmp_rssget_yt \ + && sed -n 's|.*"/channel/\([^"]*\)",.*|\1|p;' tmp_rssget_yt | head -1) + feed="https://www.youtube.com/feeds/videos.xml?channel_id=${channel_id}" + rm tmp_rssget_yt ;; esac echo "$feed" } +getTelegramRss() { + username=$(echo "$1" | sed 's|.*/t.me/||') + echo "https://rss-bridge.org/bridge01/?action=display&username=$username&bridge=TelegramBridge&format=Atom" +} + getVimeoRss() { local url="$1" if echo "$url" | grep -q "/videos$"; then @@ -83,12 +96,12 @@ if [ -n "$1" ] ; then url="$1" else url="$(xclip -selection clipboard -o)" - [ -z "$url" ] && echo "usage: $0 url 'tag1 tag2 tag3'" && exit 1 + [ -z "$url" ] && echo "usage: $0 url 'tag1 tag2 tag3 # comment'" && exit 1 fi declare -a list=() -yt_regex="^(http(s)?://)?((w){3}\.)?(youtube\.com|invidio\.us|invidious\.flokinet\.to|invidious\.materialio\.us|iv\.datura\.network|invidious\.perennialte\.ch|invidious\.fdn\.fr|invidious\.private\.coffee|invidious\.protokolla\.fi|invidious\.privacyredirect\.com|yt\.artemislena\.eu|yt\.drgnz\.club|invidious\.incogniweb\.net|yewtu\.be|inv\.tux\.pizza|invidious\.reallyaweso\.me|iv\.melmac\.space|inv\.us\.projectsegfau\.lt|inv\.nadeko\.net|invidious\.darkness\.services|invidious\.jing\.rocks|invidious\.privacydev\.net|inv\.in\.projectsegfau\.lt|invidious\.drgns\.space)/(channel|user|c).+" +yt_regex="^(http(s)?://)?((w){3}\.)?(youtube\.com|invidio\.us|invidious\.flokinet\.to|invidious\.materialio\.us|iv\.datura\.network|invidious\.perennialte\.ch|invidious\.fdn\.fr|invidious\.private\.coffee|invidious\.protokolla\.fi|invidious\.privacyredirect\.com|yt\.artemislena\.eu|yt\.drgnz\.club|invidious\.incogniweb\.net|yewtu\.be|inv\.tux\.pizza|invidious\.reallyaweso\.me|iv\.melmac\.space|inv\.us\.projectsegfau\.lt|inv\.nadeko\.net|invidious\.darkness\.services|invidious\.jing\.rocks|invidious\.privacydev\.net|inv\.in\.projectsegfau\.lt|invidious\.drgns\.space)/(channel|user|c|@|watch).+" reddit_regex="^(http(s)?://)?((w){3}\.)?reddit\.com.*" vimeo_regex="^(http(s)?://)?((w){3}.)?vimeo\.com.*" if echo $url | grep -Ex "$yt_regex" >/dev/null ; then @@ -100,6 +113,8 @@ elif echo $url | grep -E "$vimeo_regex" >/dev/null ; then list="$(getVimeoRss "$url")" elif echo $url | grep -E "github.com" >/dev/null ; then list="$(getGithubRss "$url")" +elif echo $url | grep -E "t.me" >/dev/null ; then + list="$(getTelegramRss "$url")" # gitlab also works with getlink elif echo $url | grep -E "gitlab.com/[a-zA-Z0-9].*" >/dev/null ; then list="$(getGitlabRss "$url")" From 21779072aab85599d149a71738272e3cccb724ad Mon Sep 17 00:00:00 2001 From: Oleksandr Miliukhin Date: Tue, 8 Jul 2025 15:48:32 +0300 Subject: [PATCH 2/2] bookmark - bookmark links, RSS feeds, and songs --- .local/bin/bookmark | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 .local/bin/bookmark diff --git a/.local/bin/bookmark b/.local/bin/bookmark new file mode 100755 index 00000000..f6cde9ff --- /dev/null +++ b/.local/bin/bookmark @@ -0,0 +1,25 @@ +#!/bin/sh + +getbookmark() { + bookmark="$(xclip -selection clipboard -o)" + tags=$(echo "" | dmenu -p "Enter bookmark tags (ENTER to save without tags)") +} + +write_to_file () { + if grep -q -E "^$bookmark( |$)" "$file"; then + notify-send "Already bookmarked $bookmark!" + else + notify-send "Bookmarked $bookmark" + echo "$bookmark" "$tags" >> "$file" + echo "$bookmark" | xclip -selection clipboard -i + fi +} + +case "$(printf "šŸ“œ rss\nšŸŒ url\nšŸŒšŸ“œ site (rss + url)\nšŸŽµ song" | dmenu -i -p 'Bookmark: ')" in + 'šŸŒšŸ“œ site (rss + url)') getbookmark && rssget "$bookmark" "$tags" && file="$HOME/.local/share/larbs/snippets" && write_to_file ;; + 'šŸ“œ rss') getbookmark && rssget "$bookmark" "$tags" ;; + 'šŸŒ url') getbookmark && file="$HOME/.local/share/larbs/snippets" && write_to_file ;; + 'šŸŽµ song') bookmark="$(mpc | sed "/^volume:/d;s/\\&/&/g;s/\\[paused\\].*/āø/g;/\\[playing\\].*/d;/^ERROR/Q")" + file="$HOME/.local/share/larbs/songlog" && write_to_file ;; + *) exit 1 ;; +esac