Skip to content

SW_RSS FileWriter

Rolf Obrecht edited this page Feb 27, 2023 · 26 revisions

RSS File Writer

The RSS file writer tool resides in piTelex' subdirectory RSS and is part of the newsfeed functionality of piTelex. It collects messages from a configurable newsfeed, re-formats them according to the limits of an ITA2 teleprinter and stores the output ready for further processing by the module News, which is responsible for printing incoming messages from rssFileWriter.py at the teleprinter.

Requirements

Python
module
Install
html2text pip3 install html2text
feedparser pip3 instal feedparser

Command Line Arguments

rssFileWriter.py takes several command line parameters:

Arg.
short
Arg.
long
Default Description
-u --feedurl https://www.faz.net/rss/aktuell RSS feed URL
-t --timeout 10 timeout(seconds) between fetching feed updates
-f --forget-past false Don't look back"
-p --ouput-path ./ Output files path (where News looks for messages)
-n --visible-name empty Prepend this string to each heading
-s --split-lines 69 max. # of characters per line

Example (linux):

./rssFileWriter.py -f -s 65 -n ARD-Tagesschau  -p ./news/ -u https://www.tagesschau.de/xml/rss2

will collect messages from German TV (ARD) news magazine (Tagesschau), reformat it and store the output under ./news/.

Hint: Remember to create the output path before calling rssFileWriter.py

Helper Script

The RSS subdirectory contains also a small bash helper script rss-feed for Linux that allows you to start/stop several RSS feeds simultaneously. It is configured by a few variables you will find in the first lines of code:

Var default Description
RSSROOT /home/pi/piTelex/RSS-feed base directory for the RSS news system
NEWS $RSSROOT/news Output files path (where News looks for messages)
LOG $NEWS/log Directory for logfiles
LINELENGTH 65 see -s above
CFG $RSSROOT/newsfeeds.cfg file which holds the information about the RSS feeds to monitor.

Each line of this file contains a definition of a RSS feed and is divided into three fields:

<identifier> <whitespace> <url> [<whitespace> <interval in seconds>]
  • <identifier> must not contain whitespace.
  • # as first non-whitespace-char in a line marks it as comment. Empty lines are permitted.
  • <interval in seconds> specifies the polling interval; if omitted, it defaults to 10s (which is probably too fast in most cases...)

Example:

# Name of service and URL of service
FAZ 		https://www.faz.net/rss/aktuell/

ARD-Tagesschau	https://www.tagesschau.de/xml/rss2 240

Finally, the script can be called as follows:

Cmd Description
rss-feed list list all enabled newsfeeds from config file
rss-feed start [feedname] fire up all or one specified newsfeed(s) in config file
rss-feed status list all running newsfeeds
rss-feed stop [feedname] stop all or one selected running newsfeed(s)
rss-feed help display help

Hint: if necessary, make rss-feedexecutable (chmod +x rss-feed)

Clone this wiki locally