rsstail.py
rsstail.py copied to clipboard
-w --newer switch using proper date syntax causes crash
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.
has anyone found a fix or workaorund for this ?
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.
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
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.