Clean up bin/prowl-rss
This commit is contained in:
parent
12425a0517
commit
01a304c732
|
@ -46,7 +46,7 @@ def prowl_post(api, app=None, event=None, desc=None, priority=0):
|
||||||
if resp['status'] == '200':
|
if resp['status'] == '200':
|
||||||
return True
|
return True
|
||||||
elif resp['status'] == '401':
|
elif resp['status'] == '401':
|
||||||
raise Exception("Auth Failed: %s" % content)
|
raise Exception("Auth Failed: {0}".format(content))
|
||||||
else:
|
else:
|
||||||
raise Exception("Failed")
|
raise Exception("Failed")
|
||||||
|
|
||||||
|
@ -65,21 +65,33 @@ try:
|
||||||
fo = open(GUID_FILE, "a")
|
fo = open(GUID_FILE, "a")
|
||||||
for feed in feeds:
|
for feed in feeds:
|
||||||
f = feed.split(' ', 1)
|
f = feed.split(' ', 1)
|
||||||
|
print("-- Parsing {0}".format(f[0]))
|
||||||
xml = feedparser.parse(f[0])
|
xml = feedparser.parse(f[0])
|
||||||
|
|
||||||
for e in xml.entries:
|
for e in xml.entries:
|
||||||
if e.guid not in guids:
|
title = e.title.encode('utf-8')
|
||||||
|
try:
|
||||||
|
guid = e.guid
|
||||||
|
except Exception:
|
||||||
|
guid = e.link
|
||||||
|
if guid not in guids:
|
||||||
|
print("-- Looking")
|
||||||
if len(f) > 1 and not re.match(f[1], e.title):
|
if len(f) > 1 and not re.match(f[1], e.title):
|
||||||
|
print("-- Does not match! Ignoring")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
prowl_post(apikey, "RSS", e.title, "{0} - {1} <{2}>".format(e.title, xml.feed.title, e.link))
|
print("-- Found, reporting: {0}".format(title))
|
||||||
|
|
||||||
fo.write(e.guid+"\n")
|
msg = "{0} - {1}".format(xml.feed.title.encode('utf-8'), title)
|
||||||
|
prowl_post(apikey, "RSS", title, msg)
|
||||||
|
|
||||||
guids.append(e.guid)
|
print("-- Writing to guids")
|
||||||
print("Found: {0} => {1}".format(e.title, e.link))
|
fo.write("{0}\n".format(guid))
|
||||||
|
guids.append(guid)
|
||||||
|
|
||||||
|
print("Found: {0} => {1}".format(title, e.link))
|
||||||
else:
|
else:
|
||||||
print("Ignored: {0} => {1}".format(e.title, e.link))
|
print("Ignored: {0} => {1}".format(title, e.link))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
fo.close()
|
fo.close()
|
||||||
|
|
Loading…
Reference in a new issue