-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrssntfy.py
executable file
·84 lines (69 loc) · 1.77 KB
/
rssntfy.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/python3
import os, time, importlib
try:
import feedparser
except:
print("feedparser missing\r\npip3 install feedparser")
raise SystemExit()
# settings
timer = 300 # 5 minutes
notify = False
plugin = "pushover"
daily = False
hour = "09"
today = time.strftime("%d")
daily_finds = []
daily_sent = False
if os.path.isfile("feeds.txt"):
feeds = filter(None, open("feeds.txt", "r").read().splitlines())
else:
print("Failed to read in feeds.txt")
raise SystemExit()
if os.path.isfile("keywords.txt"):
keywords = filter(None, open("keywords.txt", "r").read().splitlines())
else:
print("Failed to read in keywords.txt")
raise SystemExit()
if not os.path.exists("findings"):
os.mkdir("findings")
if notify:
try:
module = "plugins.%s" % plugin
ntfy = importlib.import_module(module)
except:
print("Failed to load plugin %s" % plugin)
raise SystemExit()
def do_ntfy(keyword, title, url):
if daily:
# add keyword,url to daily_finds
# check if sent
# blah
print("daily")
else:
ntfy.SendMessage(keyword, title, url)
def check_finding(keyword, title, url):
if os.path.exists("findings/%s.txt" % keyword):
with open("findings/%s.txt" % keyword, "r") as kf:
stored_urls = kf.read().splitlines()
if url not in stored_urls:
print("[*] Found: %s" % title)
if notify:
do_ntfy(keyword, title, url)
else:
print("[*] Found: %s" % title)
if notify:
do_ntfy(keyword, title, url)
with open("findings/%s.txt" % keyword, "a") as kf:
kf.write("%s\r\n" % url)
def check_feeds():
for feed in feeds:
fd = feedparser.parse(feed)
for keyword in keywords:
for entry in fd.entries:
title = entry.title.lower()
if keyword in title:
check_finding(keyword, title, entry.link)
while True:
print("Checking feeds...")
check_feeds()
time.sleep(timer)