-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathYRG.sh
executable file
·71 lines (55 loc) · 1.36 KB
/
YRG.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
#__ ______ ____
#\ \ / / _ \ / ___|
# \ V /| |_) | | _
# | | | _ <| |_| |
# |_| |_| \_\\____|
#
# Youtube RSS Generator
# A simple bash script to generate RSS urs for a particular youtube channel from its handle
# example usage: ./YRG.sh https://www.youtube.com/@handle
#
#Some colors
RESET='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
# Color Functions
ERED() {
echo -e "${RED}$@${RESET}"
}
EGREEN() {
echo -e "${GREEN}$@${RESET}"
}
EYELL() {
echo -e "${YELLOW}$@${RESET}"
}
EBLUE() {
echo -e "${BLUE}$@${RESET}"
}
filtercmd="sed -n 's/.*\(https:\/\/www\.youtube\.com\/channel\/[a-zA-Z0-9_-]\{24\}\).*/\1/p' | sort | uniq"
# Define the filter function
function filter(){
if [[ -z "$url" ]]; then
echo "Usage: filter <url>"
return 1
fi
curl -s "$url" | eval "$filtercmd"
}
function filter_it(){
filtered_output=$(filter "$url")
channel_id="${filtered_output#*channel/}"
converted_url="https://www.youtube.com/feeds/videos.xml?channel_id=$channel_id"
EGREEN URL WITH ID:
echo -e $filtered_output
EBLUE RSS URL:
echo -e $converted_url
echo
}
for handles in "$@"; do
channel_name="$( echo $handles | awk -F '@' '{print $2}')"
url="$( echo $handles | awk -F '@' '{print "@"$2}' | awk -F '/' '{print "https://www.youtube.com/"$1}')"
EYELL CHANNEL: $channel_name
filter_it
done