i did it! i got a feed bot up and running! and i think i figured out why the earlier attempts failed.
while i worked on this bit of code today:
if mktime(items.entries[0].published_parsed) > check:
print('new blog entry... posting')
...
else:
print('no new blog entries')
i realised that published_parsed
in the feedparser object is actually in UTC time. published
is in local time. which means whenever i ran my feed reader code, the last post was always after last check time. and i don't know how i missed that before except to blame it on ME/CFS brain fog. (more on that in another post ...)
at least i think that's what it is... i will work on the feed reader code tomorrow. maybe i can get my feeds up and running this time around.
btw: can i just say that python is just fucking awesome? in which other language can you write a line like this...
check=mktime(dt.strptime((open('check','r').read()), '%Y-%m-%d %H:%M:%S').astimezone(tz.utc).timetuple())
... that (1) reads a string from a file, (2) converts the string to datetime, (3) make it UTC, and (4) create a tuple?
i'm going to bed ... prolly go to bed hungry cos it's almost midnight and i forgot to eat but ... whatever ...
in case the link from NIH disappears, i saved it on my nextcloud