Files
opalfiles/.local/bin/yt2rss

21 lines
407 B
Bash
Executable File

#!/bin/sh
url="$1"
if [ -z "$url" ]; then
echo "Usage: yt2rss.sh <youtube_url>" >&2
exit 1
fi
html=$(curl -Ls "$url")
channel_id=$(printf '%s\n' "$html" | grep -oE 'https://www.youtube.com/channel/UC[[:alnum:]_-]+' | head -n1 | sed 's|.*/||')
if [ -z "$channel_id" ]; then
echo "Could not find channel ID." >&2
exit 1
fi
echo "https://www.youtube.com/feeds/videos.xml?channel_id=$channel_id"