I really turned annoyed by some posts in an RSS feed, because there were a lot of them and I usually never read them. I wanted to filter them out of the RSS feed automatically in Liferea. I found out that this RSS reader can use scripts to filter the RSS: I then decided to create some bash script to achieve my goal. The principle is really easy: generate some XSL file, apply it on the feed and remove it. The script receives the feed on the standard input and has to provide the filtered feed on the standard output.

Some infos about the filtering scripts and how to apply them are available in Liferea's documentation.

Here is the script filtering on the start of the title element:

#!/bin/sh

cat >> /tmp/$$.xsl << EOF
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:dc="http://purl.org/dc/elements/1.1/">

    <xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
EOF

# One element per line before EOF 
while read blacklisted
do
    echo "<xsl:template match=\"//item[starts-with( title, '$blacklisted' )]\"/>" >> /tmp/$$.xsl
done << EOF
Blacklisted post
No thanks
EOF

echo "</xsl:stylesheet>" >> /tmp/$$.xsl

xsltproc /tmp/$$.xsl -

rm /tmp/$$.xsl