From 1f34fcdcd076003326a385db958b64820211dd78 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 23 Feb 2021 23:42:33 +0100 Subject: news candyman: add more helpers --- krebs/2configs/news.nix | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'krebs/2configs/news.nix') diff --git a/krebs/2configs/news.nix b/krebs/2configs/news.nix index a6cf02c1..410beb04 100644 --- a/krebs/2configs/news.nix +++ b/krebs/2configs/news.nix @@ -122,13 +122,36 @@ add-youtube.filename = pkgs.writeDash "add-youtube" '' set -euf if [ "$#" -ne 1 ]; then - echo 'usage: ${name}: add-youtube $nick $channelid' + echo 'usage: ${name}: add-youtube $nick $channel/video/stream/id' exit 1 fi youtube_nick=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]') - youtube_id=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][1]') + youtube_url=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][1]') + if [ ''${#youtube_url} -eq 24 ]; then + youtube_id=$youtube_url + else + youtube_id=$(${pkgs.youtube-dl}/bin/youtube-dl --max-downloads 1 -j "$youtube_url" | ${pkgs.jq}/bin/jq -r '.channel_id') + fi echo "brockman: add yt_$youtube_nick http://rss.r/?action=display&bridge=Youtube&context=By+channel+id&c=$youtube_id&duration_min=&duration_max=&format=Mrss" ''; + add-twitch.filename = pkgs.writeDash "add-twitch" '' + set -euf + if [ "$#" -ne 1 ]; then + echo 'usage: ${name}: add-twitch $handle' + exit 1 + fi + twitch_nick=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]') + echo "brockman: add twitch_$twitch_nick http://rss.r/?action=display&bridge=Twitch&channel=$twitch_nick&type=all&format=Atom" + ''; + add-twitter.filename = pkgs.writeDash "add-twitter" '' + set -euf + if [ "$#" -ne 1 ]; then + echo 'usage: ${name}: add-twitter $handle' + exit 1 + fi + twitter_nick=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]') + echo "brockman: add tw_$twitter_nick http://rss.r/?action=display&bridge=Twitch&channel=$twitter_nick&type=all&format=Atom" + ''; search.filename = pkgs.writeDash "search" '' set -euf if [ "$#" -ne 1 ]; then -- cgit v1.2.3