#!/bin/bash URLS_FILE=~/.config/newsboat/youtube-urls if [[ "$1" == "sub" ]]; then if [[ -n "$2" ]]; then link="$2" else echo 'Provide channel link:' read link fi html_file=`mktemp` curl --silent $link > $html_file channel_id=`yt-channel-id $link` channel_name=`pup --file $html_file 'meta[property="og:title"]' attr{content}` rm $html_file if [[ -z "$channel_id" ]]; then echo "Failed to parse channel ID" exit 1 fi feed_url="https://www.youtube.com/feeds/videos.xml?channel_id=$channel_id" echo "$feed_url video \"~$channel_name\"" >> "$URLS_FILE" echo "Added channel: $channel_name" exit 0 fi newsboat -u "$URLS_FILE" -c ~/.local/share/newsboat/youtube-cache.db