diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-08-30 08:23:45 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-08-30 08:23:45 +0200 |
commit | 3f8594ee04d2a3d9b40a259daf3b564a53b510fa (patch) | |
tree | 66ed50643cdc81af813b5771a99732d0f78bb618 /bin/common/y2feed | |
parent | 45d39ae0c67bb086f4df0c366b251e06c888408d (diff) | |
parent | 333aaf38c66a1e4ba41d3acea38b21613c0075b2 (diff) |
Merge branch 'main' of db: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" |