diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-06-30 21:14:58 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-06-30 21:14:58 +0900 |
| commit | d8661bdfa20db5f682bc7aa9dd212c59e3073ef4 (patch) | |
| tree | 4f45c06c75a39e93fa8376ba3e96644818aaa01c /ar/.local | |
| parent | 34dde4c6819f59c2bac300cf98fffb2349d09aba (diff) | |
updates
Diffstat (limited to 'ar/.local')
| -rwxr-xr-x | ar/.local/bin/rssadd | 2 | ||||
| -rwxr-xr-x | ar/.local/bin/rssget | 149 |
2 files changed, 81 insertions, 70 deletions
diff --git a/ar/.local/bin/rssadd b/ar/.local/bin/rssadd index a49c5f8..f78a538 100755 --- a/ar/.local/bin/rssadd +++ b/ar/.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/ar/.local/bin/rssget b/ar/.local/bin/rssget index 5d470b4..f51ecb3 100755 --- a/ar/.local/bin/rssget +++ b/ar/.local/bin/rssget @@ -12,104 +12,115 @@ # This script requires rssadd to add feeds to the list. -getlink () { - local url="$1" - feeds="$(curl -s "$url" | grep -Ex '.*type=.*(rss|rdf|atom).*' | sed 's/ //g')" - url="$(echo $url | sed 's|^\(https://[^/]*/\).*|\1|')" - - for rsspath in $feeds; do - rsspath="$(echo $rsspath | sed -n "s|.*href=['\"]\([^'\"]*\)['\"].*|\1|p")" - if echo "$rsspath" | grep "http" > /dev/null; then - link="$rsspath" - elif echo "$rsspath" | grep -E "^/" > /dev/null; then - link="$url$(echo $rsspath | sed 's|^/||')" - else - link="$url$rsspath" - fi - echo $link - done +getlink() { + local url="$1" + feeds="$(curl -s "$url" | grep -Ex '.*type=.*(rss|rdf|atom).*' | sed 's/ //g')" + url="$(echo $url | sed 's|^\(https://[^/]*/\).*|\1|')" + + for rsspath in $feeds; do + rsspath="$(echo $rsspath | sed -n "s|.*href=['\"]\([^'\"]*\)['\"].*|\1|p")" + if echo "$rsspath" | grep "http" >/dev/null; then + link="$rsspath" + elif echo "$rsspath" | grep -E "^/" >/dev/null; then + link="$url$(echo $rsspath | sed 's|^/||')" + else + link="$url$rsspath" + fi + echo $link + done } getRedditRss() { - echo "${1%/}.rss" + echo "${1%/}.rss" } getYoutubeRss() { - local url="$1" - path=$(echo "$url" | sed -e 's|^http[s]*://||') - case "$path" in - *"/channel/"*) channel_id="$(echo $path | sed -r 's|.*channel/([^/]*).*|\1|')" && feed="https://www.youtube.com/feeds/videos.xml?channel_id=${channel_id}" ;; - *"/c/"*|*"/user/"*) - feed=$(wget -q "$url" -O tmp_rssget_yt \ - && sed -n 's|.*\("rssUrl":"[^"]*\).*|\1|; p' tmp_rssget_yt \ - | grep rssUrl \ - | sed 's|"rssUrl":"||') ;; - esac - echo "$feed" + local url="$1" + path=$(echo "$url" | sed -e 's|^http[s]*://||') + case "$path" in + *"/channel/"*) channel_id="$(echo $path | sed -r 's|.*channel/([^/]*).*|\1|')" && feed="https://www.youtube.com/feeds/videos.xml?channel_id=${channel_id}" ;; + *"/c/"* | *"/user/"*) + feed=$(wget -q "$url" -O tmp_rssget_yt && + sed -n 's|.*\("rssUrl":"[^"]*\).*|\1|; p' tmp_rssget_yt | + grep rssUrl | + sed 's|"rssUrl":"||') + ;; + *) + channel_id="$(curl -sA "Mozilla/5.0" "$url" | grep -Po '"rssUrl":"https://www.youtube.com/feeds/videos.xml\?channel_id=\K(UC[0-9A-Za-z_-]+)')" + feed="https://www.youtube.com/feeds/videos.xml?channel_id=${channel_id}" + ;; + esac + echo "$feed" } getVimeoRss() { - local url="$1" - if echo "$url" | grep -q "/videos$"; then - feed_url=$(echo "$url" | sed 's/\/videos$//' | sed 's/\/$/\/rss/') - else - feed_url="${url}/videos/rss" - fi - echo "$feed_url" + local url="$1" + if echo "$url" | grep -q "/videos$"; then + feed_url=$(echo "$url" | sed 's/\/videos$//' | sed 's/\/$/\/rss/') + else + feed_url="${url}/videos/rss" + fi + echo "$feed_url" } -getGithubRss () { - local url="${1%/}" - if echo $url | grep -E "github.com/[^/]*/[a-zA-Z0-9].*" >/dev/null ; then - echo "${url}/commits.atom" - echo "${url}/releases.atom" - echo "${url}/tags.atom" - elif echo $url | grep -E "github.com/[^/]*(/)" >/dev/null ; then - echo "${url}.atom" - fi +getGithubRss() { + local url="${1%/}" + if echo $url | grep -E "github.com/[^/]*/[a-zA-Z0-9].*" >/dev/null; then + echo "${url}/commits.atom" + echo "${url}/releases.atom" + echo "${url}/tags.atom" + elif echo $url | grep -E "github.com/[^/]*(/)" >/dev/null; then + echo "${url}.atom" + fi } -getGitlabRss () { - local url="${1%/}" - echo "${url}.atom" +getGitlabRss() { + local url="${1%/}" + echo "${url}.atom" } -getMediumRss () { - echo $1 | sed 's|/tag/|/feed/|' +getMediumRss() { + echo $1 | sed 's|/tag/|/feed/|' } - -if [ -n "$1" ] ; then - url="$1" +if [ -n "$1" ]; then + url="$1" else - url="$(xclip -selection clipboard -o)" - [ -z "$url" ] && echo "usage: $0 url 'tag1 tag2 tag3'" && exit 1 + url="$(xclip -selection clipboard -o)" + [ -z "$url" ] && echo "usage: $0 url 'tag1 tag2 tag3'" && exit 1 fi +tags="$2" + 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)).+" 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 - list="$(getYoutubeRss "$url")" -elif echo $url | grep -Ex "$reddit_regex" >/dev/null ; then - list="$(getRedditRss "$url")" +if echo $url | grep -Ex "$yt_regex" >/dev/null; then + list="$(getYoutubeRss "$url")" + channel_name="${url##*@}" + [ -z "$tags" ] && tags="\"~$channel_name\" Youtube" +elif echo $url | grep -Ex "$reddit_regex" >/dev/null; then + list="$(getRedditRss "$url")" # vimeo actually works with getlink -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 "$vimeo_regex" >/dev/null; then + list="$(getVimeoRss "$url")" +elif echo $url | grep -E "github.com" >/dev/null; then + list="$(getGithubRss "$url")" + repo="${url##*/}" + author="${url%/*}" + author="${author##*/}" + [ -z "$tags" ] && tags="\"~$author's $repo\" Git" # gitlab also works with getlink -elif echo $url | grep -E "gitlab.com/[a-zA-Z0-9].*" >/dev/null ; then - list="$(getGitlabRss "$url")" -elif echo $url | grep -E "medium.com/tag" >/dev/null ; then - list="$(getMediumRss "$url")" +elif echo $url | grep -E "gitlab.com/[a-zA-Z0-9].*" >/dev/null; then + list="$(getGitlabRss "$url")" +elif echo $url | grep -E "medium.com/tag" >/dev/null; then + list="$(getMediumRss "$url")" else - list="$(getlink "$url")" + list="$(getlink "$url")" fi [ "$(echo "$list" | wc -l)" -eq 1 ] && chosen_link="$list" || chosen_link=$(printf '%s\n' "${list[@]}" | dmenu -p "Choose a feed:") -tags="$2" ifinstalled rssadd && rssadd "$chosen_link" "$tags" echo "$chosen_link" "$tags" |
