From 8d490839b7ef11549bee6c92fdd86ef60afd55e0 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Mon, 21 Jan 2019 01:25:07 -0200 Subject: Generate local RSS feed from buku tags. --- scripts/atom.js | 22 ++++++++++++++++++++++ scripts/atom.sh | 19 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 scripts/atom.js create mode 100755 scripts/atom.sh (limited to 'scripts') diff --git a/scripts/atom.js b/scripts/atom.js new file mode 100644 index 0000000..878df05 --- /dev/null +++ b/scripts/atom.js @@ -0,0 +1,22 @@ +const RSS = require('rss'); + +const feedName = process.argv[2]; +const feedSrc = process.argv[3]; + +const feed = new RSS({ + title: `Buku feed tag for '${feedName}'.`, + description: `Buku feed tag for ${feedName}`, +}); + +const items = require(feedSrc); +items.forEach(({ title, description, uri }) => { + feed.item({ + title, + description, + url: uri + }); +}); + +const xml = feed.xml({indent: true}); + +console.log(xml); diff --git a/scripts/atom.sh b/scripts/atom.sh new file mode 100755 index 0000000..73c35ec --- /dev/null +++ b/scripts/atom.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -euo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")" + +if [[ ! -d "node_modules" ]]; then + npm i rss +fi + +feed() { + local tag="$1" + local tmp="/tmp/$tag.json" + buku -t "$tag" --json > "$tmp" + node atom.js "$tag" "$tmp" +} + +mkdir -p ~/.newsboat +feed ril > ~/.newsboat/ril.xml +feed simple-archive > ~/.newsboat/simple-archive.xml +feed inbox > ~/.newsboat/inbox.xml -- cgit v1.2.3