This repository has been archived on 2021-11-29. You can view files and clone it, but cannot push or open issues or pull requests.
rsstube-bash-old/scripts/page-extractors/youtube

20 lines
592 B
Plaintext

# if page is a channel page, use canonical link to determine channel id
try1=`echo "$content" | grep -Po '(?<=<link rel="canonical" href="https://www.youtube.com/channel/).*?(?=">)'`
if [[ -n "$try1" ]]; then
channel_id="$try1"
else
# else (e.g., video page) extract just channel id from metadata
try2=`echo "$content" | grep -Po '(?<="channelId":").+?(?=")' | head -1`
if [[ -n "$try2" ]]; then
channel_id="$try2"
fi
fi
# if channel id successfully extracted
if [[ -n ${channel_id} ]]
then
rss="https://www.youtube.com/feeds/videos.xml?channel_id=${channel_id}"
page_ext=$rss
fi