The bug#
A couple days ago my Twitter screen scraper stopped working in Liferea. I hadn't changed anything, and the script's output at the command-line still looked okay to my inspection, but Liferea started giving the message
A couple days ago my Twitter screen scraper stopped working in Liferea. I hadn't changed anything, and the script's output at the command-line still looked okay to my inspection, but Liferea started giving the message
Twitter no longer offers an RSS feed. That thread offers a few workarounds which involve external or non-free services or require creating a Twitter account. One of those external services, TwitRSS.me is open-source with its code on GitHub. This code can be run locally to view Twitter streams in Liferea (or any other news aggregator) without relying on an external service.
Specifically, the Perl script twitter_user_to_rss.pl
is
the relevant part. It's intended to be used on a webserver,
so the output includes HTTP headers:
Content-type: application/rss+xml
Cache-control: max-age=1800
<?xml version="1.0" encoding="UTF-8"?>
...
which can be cleaned out with tail
in the script
twitter_user_to_rss_file
, which assumes it's in the same directory as
twitter_user_to_rss.pl
:
#!/bin/sh
"$(dirname "$0")/twitter_user_to_rss.pl" "user=$1&replies=1" \
| tail -n +4
twitter_user_to_rss_file
also handles the argument format of the
script, so it just takes a single argument which is the Twitter
username. The replies=1
part tells the script to use the Tweets &
replies
view which includes tweets that begin with @
.
When creating a subscription in Liferea, the advanced options include
a choice of source type. To use the script, set the source type to
Command
and the source to
/path/to/twitter_user_to_rss_file username
My version of twitter_user_to_rss.pl
includes
a few differences from the original that make it a bit more
usable. Most importantly, links are made into actual links (based on
this code), images are included in the feed content,
tweets are marked with their creator to make it easier to follow
retweets and combinations of tweets from multiple feeds together in a
single stream.
Liferea is a desktop news aggregator (sometimes called an RSS reader). Unlike the late Google Reader or most of its alternatives like the open-source Tiny Tiny RSS which are web-based and run on a server to be accessed via a web browser, Liferea is a separate desktop application and uses an embedded browser to view content.
Sometimes you don't actually care about all of the items in a feed and the site provides no filtering mechanism. If the uninteresting items are rare enough, you can just ignore them, but a news aggregator is most useful if it only notifies you of news items you actually might want to read.
Luckily, Liferea is very flexible. It supports running a command on
a feed which it calls a conversion filter
. I wrote
some python scripts to filter feeds by title locally.
For instance, I wanted to follow only the changelog posts in the forum feed
http://braceyourselfgames.com/forums/feed.php
,
but it includes changes to all forum topics, so I checked the Use
conversion filter
option and set the conversion filter to
/path/to/atom_filter_title.py --whitelist "Re: Change log"