diff options
| -rwxr-xr-x | youboat | 32 | ||||
| -rwxr-xr-x | yt-channel-id | 4 |
2 files changed, 36 insertions, 0 deletions
@@ -0,0 +1,32 @@ +#!/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 diff --git a/yt-channel-id b/yt-channel-id new file mode 100755 index 0000000..a412974 --- /dev/null +++ b/yt-channel-id @@ -0,0 +1,4 @@ +#!/bin/bash + +URL=$1 +curl --silent $URL | grep -Po 'channel_id=.{24}' | head -n 1 | cut -d'=' -f 2 |