m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/youboat
blob: bf1e102c40e3852c3a543196d9e48daeeb9f7665 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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