dotfiles

My collection of dotfiles
git clone git://git.noxz.tech/dotfiles
Log | Files | Refs

commit 81f346ad7feb042b357148339a4f1e2d7e1c2580
parent 8ab2c0af1c6f3284e3fcec2761422f02b1780bfa
Author: Chris Noxz <chris@noxz.tech>
Date:   Tue, 14 Jan 2020 20:13:54 +0100

[bin] Adding script for creating rss-feeds from LBRY

Diffstat:
Abin/.bin/lbry2rss | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 78 insertions(+), 0 deletions(-)

diff --git a/bin/.bin/lbry2rss b/bin/.bin/lbry2rss @@ -0,0 +1,78 @@ +#!/bin/sh +# +# usage: lbry2rss "lbry://@lbry.social#1" > lbry.social.rss +# Works with newsboat and mpv! + +CHNL="$1" + +CHNL_REQ="{ + \"jsonrpc\":\"2.0\", + \"method\":\"resolve\", + \"params\":{ + \"urls\":[\"$CHNL\"] + } +}" +CHNL_QRY=".result | to_entries[].value | .value.title,.name,.value.description" +LIST_REQ="{ + \"jsonrpc\":\"2.0\", + \"method\":\"claim_search\", + \"params\":{ + \"channel\":\"$CHNL\", + \"page\":1, + \"page_size\":15 + } +}" +LIST_QRY=".result.items[] | +.value.title, +.value.description, +\"https://api.lbry.tv/content/claims/\" + +.normalized_name+\"/\" + +.claim_id + +\"/stream\", +.permanent_url, +.meta.creation_timestamp +" + +CHNL_DATA="$(curl \ + --data-binary "$CHNL_REQ" \ + -H 'content-type:text/plain;' \ + --silent https://api.lbry.tv/api/v1/proxy \ +| jq "$CHNL_QRY" \ +| sed \ + -e 's/^"//' \ + -e 's/"$//' \ +| awk ' + NR == 1 {print "<title>"$0"</title>"} + NR == 2 {print "<link>"$0"</link>"} + NR == 3 {print "<description><![CDATA["$0"]]></description>"} +' +)" + +LIST_DATA="$(curl \ + --data-binary "$LIST_REQ" \ + -H 'content-type:text/plain;' \ + --silent https://api.lbry.tv/api/v1/proxy \ +| jq "$LIST_QRY" \ +| sed \ + -e 's/^"//' \ + -e 's/"$//' \ +| awk ' + NR % 5 == 1 {print "<item>"} + NR % 5 == 1 {print "\t<title>"$0"</title>"} + NR % 5 == 2 {gsub(/\\n/, "</p><p>"); print "\t<description><![CDATA[<p>"$0"</p>]]></description>"} + NR % 5 == 3 {print "\t<link>"$0"</link>"} + NR % 5 == 4 {print "\t<guid isPermaLink=\"false\">"$0"</guid>"} + NR % 5 == 0 {print "\t<pubDate>"strftime("%a, %d %b %Y %T %z",$0)"</pubDate>"} + NR % 5 == 0 {print "</item>"} +' \ +| sed 's:<p></p>::g' +)" + +echo '<?xml version="1.0" encoding="UTF-8" ?> +<rss version="2.0"> +<channel>' +echo "$CHNL_DATA" +echo "$LIST_DATA" +echo ' +</channel> +</rss>'