.: jus' fyrfli tings :.

  • currents
  • main
  • me
  • meta
  • puppers
  • tech

automated fedi posting in da house!

Published: Tue 12 November 2024
By fyrfli

In tech

tags: fedi python bots coding

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

resources

  • Pelican
  • Python.org
  • Flask
  • Jinja2
  • CSS-Tricks

find me

  • atom feed
  • fedi
  • gitea
  • github

powered by Pelican, fueled by Python.

Theme inspired by SimpleCSS and gently tweaked.