-
Notifications
You must be signed in to change notification settings - Fork 0
/
fff.py
32 lines (26 loc) · 758 Bytes
/
fff.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# FacebookFeedFetch for Notifications
# f4n
import feedparser
import subprocess
import StringIO
import json
import os, sys
jsonfile = 'fff.json'
old = {}
if os.path.exists(jsonfile):
old = json.load(open(jsonfile))
for url in sys.argv[1:]:
d = feedparser.parse(url)
for i in d.entries:
item = dict([(k, i[k]) for k in 'link,title,summary'.split(',')])
if i['id'] not in old:
args = ('notify-send', '-a', 'Facebook',
"""<b><a href="%(link)s">%(title)s</a></b><p>%(summary)s</p>""" % item)
p = subprocess.Popen(args)
if p.wait() != 0:
print 'return value of startup script was non-zero'
continue
old[i['id']] = item
# send libnotify stuff
print 'notified about', item
json.dump(old, file(jsonfile, 'w'), indent=4)