diff options
author | Patrick Spek <p.spek@tyil.nl> | 2020-01-18 02:01:45 +0100 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2020-01-18 02:01:45 +0100 |
commit | 5476eb43a545ff97317285fefdc494c54a560866 (patch) | |
tree | 1f490945bca80b8fa66f9ad0c5e6ad3a85fdcbe0 /.local/bin/ytrss | |
parent | 7191a1a9c48bf31ca3a0d9de60baf6931ff7cb54 (diff) |
Add new ytrss util
Diffstat (limited to '.local/bin/ytrss')
-rwxr-xr-x | .local/bin/ytrss | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/.local/bin/ytrss b/.local/bin/ytrss new file mode 100755 index 0000000..0377160 --- /dev/null +++ b/.local/bin/ytrss @@ -0,0 +1,51 @@ +#! /usr/bin/env sh + +main() +{ + # Handle opts + opts "$@" + shift "$OPTS" + unset OPTS + + # Show help + [ "$OPT_HELP_ONLY" ] && usage && exit 0 + + for url in $@ + do + curl -s "$url" \ + | grep -Eo 'https://www.youtube.com/feeds/videos.xml?[^"]+' + done +} + +opts() +{ + OPTS=0 + + while getopts ":h" opt + do + case "$opt" in + h) OPT_HELP_ONLY=1 ;; + *) + printf "Invalid option passed: %s\n" "$OPTARG" >&2 + ;; + esac + done + + unset opt +} + +usage() +{ + cat <<EOF +Usage: + $(basename "$0") -h + $(basename "$0") <url> [ <urls> ... ] + +Get the RSS feed URL of a YouTube channel through the channel's page URL. + +Options: + -h Show this help text and exit. +EOF +} + +main "$@" |