Skip to content

RSS reader

Francesco edited this page Mar 21, 2018 · 16 revisions

T-UI beta 6.4 introduced a great new feature: RSS reader. The system is pretty easy to understand, but you'll need to know what an RSS feed is, and also how XML works.

Add an RSS feed

$ rss -add [ID] [update time in seconds] [URL]

  • [ID] -> a unique number that you'll use in future to set up your RSS feed
  • [update time in seconds] -> the number of time that will pass between two RSS feed updates
  • [URL] -> the URL of your RSS feed

Remove an RSS feed

$ rss -rm [ID]

Print the content of an RSS feed

$ rss -l [ID]

Include/exclude a new item

If include_rss_default is true:

$ rss -exclude_if_matches [ID] [regex]

will create a filter which will exclude every item where [regex] can find a match.

If include_rss_default is false:

will create a filter which will include only those items where [regex] can find a match.

Update settings

Temporarily hide an RSS feed

$ rss -show [ID] [true/false]

If the second argument is false, you won't receive updates from that feed anymore, but it will be updated silently.

Change the update time

$ rss -update_time [ID] [update time in seconds]

Change the base feed color

$ rss -color [ID] [color]

Change the feed format

$ rss -format [ID] [format]

Format guidelines

%[length][color]tag

The values between square brackets ([]) are optional, feel free to exclude them if you want. tag is the name of the feed tag that you want to show ("title", "description", ...)

For instance:

%[1000][teal]title --- %[50][#00ff00]description (%pubDate)

The tag link will show a direct link (if available) to the corresponding webpage.

Defining common formats

You can define a format that you will be able to use many times inside differents RSS feeds.

$ rss -add_format [ID] [format ID]

Then, you'll just need to set the [format] value of an RSS feed to the ID that you just created:

$ rss -format [ID] [format ID]

Download message format

Values:

  • %id -> the ID associated with the RSS feed
  • %url -> the URL of the RSS feed
  • %sgb/%smb/%skb/%sb -> the downloads size in gbytes, mbytes, kbytes or bytes

RSS commands

You can ask T-UI to execute a given command when a new RSS item contains a specified set of words.

$ rss -add_command [command ID] [IDs (separated by commas)] [regex] [cmd]

  • [command ID] -> a unique number identifying this specific command
  • [IDs] -> the IDs of the RSS feeds on which you will apply the following regex.
  • [regex] -> if this finds one or more matches inside a new item, [cmd] will be executed
  • [cmd] -> the command that will be executed

Important! [regex] can't contain spaces. What is after an eventual space would be considered as part of [cmd]. To overcome the problem, replace every space inside your regex with a \s (= any type of space in regexes [tab, newline, single space]) or change the cmd editing the file rss.xml.

Groups

Regexes support a very nice feature called capturing groups. You can find more details here.

Create a new command like this:

rss -add_command [ID] [IDs] (.*) echo %1

  • (.*) -> this regex matches everything.
  • echo %1 -> this is the command that will be ran when the regex find a match. %1 means group(1), and so it will be replaced with the content of (.*).

Troubleshooting

Problem 1

Invalid publication date tag: file.xml

This happens when the RSS feed that you're trying to read uses a non-standard pubDate tag. To fix this, you just need to open the RSS feed in your browser. Then check what's the name of the tag that tells the publication date of the item.

For instance, this comes from Reddit:

<entry>
<author>
<name>/u/JavaReallySucks</name>
<uri>https://www.reddit.com/user/JavaReallySucks</uri>
</author><category term="gifs" label="r/gifs"/>
<content type="html">&lt;table&gt; &lt;tr&gt;&lt;td&gt; &lt;a href=&quot;https://www.reddit.com/r/gifs/comments/7a0qs5/transforming_werewolf_costume/&quot;&gt; &lt;img src=&quot;https://b.thumbs.redditmedia.com/MZ84Smn7zPtz2diGcJNDCGIKb2on8N03QLoa_ohtULk.jpg&quot; alt=&quot;Transforming werewolf costume&quot; title=&quot;Transforming werewolf costume&quot; /&gt; &lt;/a&gt; &lt;/td&gt;&lt;td&gt; &amp;#32; submitted by &amp;#32; &lt;a href=&quot;https://www.reddit.com/user/JavaReallySucks&quot;&gt; /u/JavaReallySucks &lt;/a&gt; &amp;#32; to &amp;#32; &lt;a href=&quot;https://www.reddit.com/r/gifs/&quot;&gt; r/gifs &lt;/a&gt; &lt;br/&gt; &lt;span&gt;&lt;a href=&quot;https://i.imgur.com/MheQHbM.gifv&quot;&gt;[link]&lt;/a&gt;&lt;/span&gt; &amp;#32; &lt;span&gt;&lt;a href=&quot;https://www.reddit.com/r/gifs/comments/7a0qs5/transforming_werewolf_costume/&quot;&gt;[comments]&lt;/a&gt;&lt;/span&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</content>
<id>t3_7a0qs5</id>
<link href="https://www.reddit.com/r/gifs/comments/7a0qs5/transforming_werewolf_costume/" />
<updated>2017-11-01T02:15:27+00:00</updated>
<title>Transforming werewolf costume</title>
</entry>

As you can see, in this case there isn't a pubDate. But you can note that the date is being held by the updated tag.

So, to fix the problem:

$ rss -date_tag [ID] updated

Problem 2

Invalid entry tag: file.xml

This happens when the RSS feed that you're trying to read uses a non-standard item tag, which is the root node of every published item. To fix this, you just need to open the RSS feed in your browser. Then check what's the name of the tag that tells the publication date of the item.

Again, this comes from Reddit:

<entry>
<author>
<name>/u/JavaReallySucks</name>
<uri>https://www.reddit.com/user/JavaReallySucks</uri>
</author><category term="gifs" label="r/gifs"/>
<content type="html">&lt;table&gt; &lt;tr&gt;&lt;td&gt; &lt;a href=&quot;https://www.reddit.com/r/gifs/comments/7a0qs5/transforming_werewolf_costume/&quot;&gt; &lt;img src=&quot;https://b.thumbs.redditmedia.com/MZ84Smn7zPtz2diGcJNDCGIKb2on8N03QLoa_ohtULk.jpg&quot; alt=&quot;Transforming werewolf costume&quot; title=&quot;Transforming werewolf costume&quot; /&gt; &lt;/a&gt; &lt;/td&gt;&lt;td&gt; &amp;#32; submitted by &amp;#32; &lt;a href=&quot;https://www.reddit.com/user/JavaReallySucks&quot;&gt; /u/JavaReallySucks &lt;/a&gt; &amp;#32; to &amp;#32; &lt;a href=&quot;https://www.reddit.com/r/gifs/&quot;&gt; r/gifs &lt;/a&gt; &lt;br/&gt; &lt;span&gt;&lt;a href=&quot;https://i.imgur.com/MheQHbM.gifv&quot;&gt;[link]&lt;/a&gt;&lt;/span&gt; &amp;#32; &lt;span&gt;&lt;a href=&quot;https://www.reddit.com/r/gifs/comments/7a0qs5/transforming_werewolf_costume/&quot;&gt;[comments]&lt;/a&gt;&lt;/span&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</content>
<id>t3_7a0qs5</id>
<link href="https://www.reddit.com/r/gifs/comments/7a0qs5/transforming_werewolf_costume/" />
<updated>2017-11-01T02:15:27+00:00</updated>
<title>Transforming werewolf costume</title>
</entry>

In this case there isn't an item. But you can note that the root of the published item is entry.

So, to fix the problem:

$ rss -entry_tag [ID] entry

Problem 3

The time format couldn't be parsed

Another time, this happens when an RSS feed doesn't follow the standard.

The standard is, in fact, this format:

EEE, d MMM yyyy HH:mm:ss Z -> Wed, 1 Nov 2017 07:46:30 +0100 or Tue, 31 Oct 2017 21:00:48 +0100

Let's take Reddit again:

<entry>
<author>
<name>/u/JavaReallySucks</name>
<uri>https://www.reddit.com/user/JavaReallySucks</uri>
</author><category term="gifs" label="r/gifs"/>
<content type="html">&lt;table&gt; &lt;tr&gt;&lt;td&gt; &lt;a href=&quot;https://www.reddit.com/r/gifs/comments/7a0qs5/transforming_werewolf_costume/&quot;&gt; &lt;img src=&quot;https://b.thumbs.redditmedia.com/MZ84Smn7zPtz2diGcJNDCGIKb2on8N03QLoa_ohtULk.jpg&quot; alt=&quot;Transforming werewolf costume&quot; title=&quot;Transforming werewolf costume&quot; /&gt; &lt;/a&gt; &lt;/td&gt;&lt;td&gt; &amp;#32; submitted by &amp;#32; &lt;a href=&quot;https://www.reddit.com/user/JavaReallySucks&quot;&gt; /u/JavaReallySucks &lt;/a&gt; &amp;#32; to &amp;#32; &lt;a href=&quot;https://www.reddit.com/r/gifs/&quot;&gt; r/gifs &lt;/a&gt; &lt;br/&gt; &lt;span&gt;&lt;a href=&quot;https://i.imgur.com/MheQHbM.gifv&quot;&gt;[link]&lt;/a&gt;&lt;/span&gt; &amp;#32; &lt;span&gt;&lt;a href=&quot;https://www.reddit.com/r/gifs/comments/7a0qs5/transforming_werewolf_costume/&quot;&gt;[comments]&lt;/a&gt;&lt;/span&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</content>
<id>t3_7a0qs5</id>
<link href="https://www.reddit.com/r/gifs/comments/7a0qs5/transforming_werewolf_costume/" />
<updated>2017-11-01T02:15:27+00:00</updated>
<title>Transforming werewolf costume</title>
</entry>

Note that the date is 2017-11-01T02:15:27+00:00, which really doesn't look like Wed, 1 Nov 2017 07:46:30 +0100.

So, we have to find the time format that this RSS feed is using. It's not very quick, but neither hard.

Take the table at this page.

After a minute or two of deep thoughts, the resulting format appears to be:

YYYY-MMM-ddTHH:mm:ssXXX

But, wait. It's not fixed yet. The last XXX causes a problem, it looks like the Android version of the parser doesn't support it. So, replace XXX with ZZZZZ (I don't know why, it's a workaround I found after some hours spent on Google).

The result is:

YYYY-MMM-ddTHH:mm:ssZZZZZ

Now take your format and use the command:

$ rss -time_format [ID] YYYY-MMM-ddTHH:mm:ssZZZZZ