dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit a95710947996e0628e90002589b6837e75601145
parent 2da788890af8bb2b2228aff33ade3548226ad9e1
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Tue, 26 Feb 2019 15:21:10 +0100

Update youtube channel id configuration and parsing

Diffstat:
Mlinks/.config/newsboat/urls | 1+
Alinks/bin/youtube-channel-id | 37+++++++++++++++++++++++++++++++++++++
Dlinks/bin/youtube-channel-id.sh | 24------------------------
Rlinks/bin/youtube-dl-music.sh -> links/bin/youtube-dl-music | 0
4 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/links/.config/newsboat/urls b/links/.config/newsboat/urls @@ -126,3 +126,4 @@ https://www.youtube.com/feeds/videos.xml?channel_id=UCm9BPmxgO7fW7_lOXl9-mPw you https://www.youtube.com/feeds/videos.xml?channel_id=UCzFfuU06f327-bnI3lODUNQ youtube "~youtube: LinuxChristian" https://www.youtube.com/feeds/videos.xml?channel_id=UCMx-iVKPpKiRPQfc39nXvXw youtube "~youtube: David Lundbek Egholm" https://www.youtube.com/feeds/videos.xml?channel_id=UCUC_2Z23y5wGOVG2X1ulCCg youtube "~youtube: Fasanfjer" +https://www.youtube.com/feeds/videos.xml?channel_id=UCR4s1DE9J4DHzZYXMltSMAg youtube "~youtube: HowToBasic" diff --git a/links/bin/youtube-channel-id b/links/bin/youtube-channel-id @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +function help { + echo "Usage: ${0##*/} <youtube-url>" + echo "or: ${0##*/} <youtube-channel-name>" +} + +[ $# -lt 1 ] && help && exit 1 +[ "$1" = "-h" ] && help && exit 0 +[ "$1" = "--help" ] && help && exit 0 + +[ $# -eq 1 ] && url="$1" +[ $# -eq 2 ] && url="$2" + +# detect if url or just channel name +if ! [[ "$url" =~ ^(http:\/\/|https:\/\/).*$ ]]; then + url="https://www.youtube.com/user/$url" +fi + +id="$(curl --silent "$url" | \ + grep 'data-channel-external-id' | \ + sed 's/.*data-channel-external-id="//' | \ + sed 's/".*//' | \ + sed '1q')" +name="$(echo "$url" | sed 's/.*\///' )" + +if [ "$1" = "add" ]; then + echo -n "https://www.youtube.com/feeds/videos.xml?channel_id=${id} " \ + >> ~/.config/newsboat/urls + + echo "youtube \"~youtube: $name\"" >> ~/.config/newsboat/urls + + echo "$name ($id) added" +else + echo "$id" + echo "$id" | xclip +fi diff --git a/links/bin/youtube-channel-id.sh b/links/bin/youtube-channel-id.sh @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -function help { - echo "Usage: ${0##*/} <youtube-url>" -} - -[ $# -lt 1 ] && help && exit 1 - -[ $# -eq 1 ] && url="$1" -[ $# -eq 2 ] && url="$2" - -id="$(curl --silent "$url" | \ - grep 'data-channel-external-id' | \ - sed 's/.*data-channel-external-id="//' | \ - sed 's/".*//' | \ - sed '1q')" - -if [ "$1" = "add" ]; then - echo "https://www.youtube.com/feeds/videos.xml?channel_id=${id} \"YouTube Subscriptions\"" >> ~/.config/newsboat/urls - echo "$id added" -else - echo "$id" - echo "$id" | xclip -fi diff --git a/links/bin/youtube-dl-music.sh b/links/bin/youtube-dl-music