rsstail.py icon indicating copy to clipboard operation
rsstail.py copied to clipboard

-w --newer switch using proper date syntax causes crash

Open ghost opened this issue 3 years ago • 4 comments

rsstail -dl -U -a -s -n 1 -w "2021/03/20 13:00:00" -u https://feed.com/rss !

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/feedparser/util.py", line 156, in __getattr__
    return self.__getitem__(key)
  File "/usr/local/lib/python3.7/dist-packages/feedparser/util.py", line 113, in __getitem__
    return dict.__getitem__(self, key)
KeyError: 'date_parsed'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/rsstail/main.py", line 433, in main
    tick(feeds, opts, formatter, seen_id_hashes, iteration)
  File "/usr/local/lib/python3.7/dist-packages/rsstail/main.py", line 343, in tick
    entries = [entry for entry in entries if entry.date_parsed > opts.newer]
  File "/usr/local/lib/python3.7/dist-packages/rsstail/main.py", line 343, in <listcomp>
    entries = [entry for entry in entries if entry.date_parsed > opts.newer]
  File "/usr/local/lib/python3.7/dist-packages/feedparser/util.py", line 158, in __getattr__
    raise AttributeError("object has no attribute '%s'" % key)
AttributeError: object has no attribute 'date_parsed'

Also, seems that if I do not want it to initially print anything, -n 0 should allow for that but after a few moments it prints the articles anyway.

ghost avatar Mar 20 '21 14:03 ghost

has anyone found a fix or workaorund for this ?

Robert-Riedl avatar Feb 11 '22 11:02 Robert-Riedl

I believe I have traced back the issue to feedparser not being able to parse dates properly. For example, take a look at this issue.

KrisMinchev avatar Sep 29 '22 13:09 KrisMinchev

Using latest of feedparser and rsstail with pip did not solve the issue.

I don't know enough python to tell, if its a bug or not used correctly

Robert-Riedl avatar Oct 06 '22 12:10 Robert-Riedl

Also, seems that if I do not want it to initially print anything, -n 0 should allow for that but after a few moments it prints the articles anyway.

What I'm doing to solve this is wrapping it in a script (with a little help from Stack Exchange):

i=1 n=0
rsstail -i 60 -n 1 -u http://example.com/rss --format 'New Post: %(title)s | Link: %(link)s\n' | while read line
do
((n >= i )) && echo $line
((n++))
done

This does the initial 1 post, but discards it, then prints the new posts afterwards when they're posted.

My speculation on this is that it's basically assuming that -n 0 is the same as not setting -n at all. Unfortunately my python knowledge isn't quite there to figure out a better fix. However, I was using this for a bash script anyways that I was going to wrap around this and use the output, so that seemed like an easier solution for my use case.

trekkie1701c avatar Jul 08 '23 21:07 trekkie1701c