summaryrefslogtreecommitdiff
path: root/bin/common/y2feed
blob: b55d66b1ec8925ce2b91f66edd961f22c255f24c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

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"