yt-feedurl.sh - dotfiles - These are my dotfiles. There are many like it, but these are mine.
(HTM) git clone git://jay.scot/dotfiles
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
yt-feedurl.sh (532B)
---
1 #!/bin/sh
2
3 # Check if a YouTube URL is provided
4 if [ -z "$1" ]; then
5 echo "Usage: $0 <youtube_url>"
6 exit 1
7 fi
8
9 # Fetch the HTML content of the YouTube page
10 youtube_url="$1"
11 html_content=$(curl -s "$youtube_url")
12
13 # Extract the application/rss+xml URL using grep
14 rss_url=$(echo "$html_content" | grep -o 'https://www.youtube.com/feeds/videos.xml[^"]*')
15
16 # Check if the RSS URL is found
17 if [ -z "$rss_url" ]; then
18 echo "Unable to find the application/rss+xml URL on the provided YouTube page."
19 exit 1
20 fi
21
22 echo "RSS URL: $rss_url"