Este script básicamente lee el feed de Underc0de cada minuto, y si encuentra un post nuevo, envía una notificación a la bandeja del sistema con un botón para leer el post.
Cabe notar que solo funciona en Linux (aunque se puede adaptar para que ande en Windows usando wxWidgets, por ejemplo), y requiere de la librería python3-notify2 y python3-feedparser.
#!/usr/bin/env python
from gi.repository import Gtk
from gi.repository import GLib
import notify2
import sys
import feedparser
import webbrowser
lasturl = ''
def ir_cb(n, action):
assert action == "ir"
webbrowser.open(lasturl)
n.close()
def rssTimer(*args):
global lasturl
print("f1")
feed = feedparser.parse("https://underc0de.org/foro/index.php?type=rss;action=.xml")
print("f2")
if feed['items'][0]['id'] != lasturl:
lasturl = feed['items'][0]['id']
notify2.init("RSS", mainloop='glib')
n = notify2.Notification("Nuevo post en la sección de " + feed['items'][0]['tags'][0]['term'],
"Tema: " + feed['items'][0]['title'])
n.add_action("ir", "Ir", ir_cb)
n.show()
return True
if __name__ == '__main__':
if not notify2.init("RSS", mainloop='glib'):
sys.exit(1)
feed = feedparser.parse("https://underc0de.org/foro/index.php?type=rss;action=.xml")
lasturl = feed['items'][0]['id']
GLib.timeout_add_seconds(60, rssTimer)
Gtk.main()
Im-pre-sio-nan- Genial - te. :o
Lamentablemente uso Window$, así que no he probado el programa.
Aún así, es increible.
Saludos!