diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-08-22 23:08:50 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-08-22 23:08:50 +0200 |
commit | 067b271a243dafcf652fe7cfe85e723d25ff1a64 (patch) | |
tree | c546402b2c40ca1e0739d1cc404f1d04d1d45067 /bin/common/y2feed | |
parent | 67a2df82d25f52ea0937f4eed355546deae7b4b5 (diff) | |
parent | 9172676556847ff625cbf4b4eff19f441e0b9386 (diff) |
Merge branch 'main' of /var/git/dotfiles
Diffstat (limited to 'bin/common/y2feed')
-rwxr-xr-x | bin/common/y2feed | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/bin/common/y2feed b/bin/common/y2feed index e30bccf..b55d66b 100755 --- a/bin/common/y2feed +++ b/bin/common/y2feed @@ -1,5 +1,18 @@ #!/bin/sh -echo "url: $1" >&2 -curl -L -s "$1" | - pup 'link[title=RSS] attr{href}' | - tee /dev/stderr + +get_feed() +{ + link="$(curl -L -s "$1" | pup 'link[title=RSS] attr{href}' 2>/dev/null)" + [ "$link" ] && printf "%s\n" "$link" | tee /dev/stderr && exit +} + +[ "$1" ] || exit 1 + +# url is channel +get_feed "$1" + +part="$(echo "$1" | awk -F '/' '{print $NF}')" +# last part is channel id +get_feed "https://www.youtube.com/channel/$part" +# last part is channel tag +get_feed "https://www.youtube.com/$part" |