-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrss.py
More file actions
52 lines (42 loc) · 1.58 KB
/
Copy pathrss.py
File metadata and controls
52 lines (42 loc) · 1.58 KB
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
from time import sleep
import feedparser
import plugin
defaults = {
'rss_feeds': {},
'rss_interval': 150,
}
class Plugin(plugin.Plugin):
"""
<pyfoot> is capable of reading an RSS feed into a channel, but it's not
configurable live. Talk to whoever is operating your local pyfoot instance
if you have a feed you'd like in a channel.
"""
def prepare(self):
self.latestitem = {}
for channel in self.conf['rss_feeds']:
# get latest item, remember to ignore it
urls = self.conf['rss_feeds'][channel]
for url in urls:
try:
feed = feedparser.parse(url)
self.latestitem[url] = feed['items'][0]
except:
pass
def run(self):
while True:
sleep(self.conf['rss_interval'])
for channel in self.conf['rss_feeds']:
urls = self.conf['rss_feeds'][channel]
for url in urls:
try:
feed = feedparser.parse(url)
item = feed['items'][0]
except:
pass
else:
if item['link'] != self.latestitem[url]['link']:
self.latestitem[url] = feed['items'][0]
title = self.latestitem[url]['title']
link = self.latestitem[url]['link']
self.irc.privmsg(channel, '%s | %s' % (
title, link), pretty=True)