-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrss.py
60 lines (46 loc) · 1.14 KB
/
rss.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
#!/usr/bin/python
import feedparser
import time
import sys
from escpos.printer import Serial
import hashlib
import time
import ast
import json
import io
print('Boop')
p = Serial(devfile='/dev/tty.usbserial-14120',
baudrate=9600,
bytesize=8,
parity='N',
stopbits=1,
timeout=1.00,
dsrdtr=True)
feed_name = sys.argv[1]
url = sys.argv[2]
rssPR = feedparser.parse(url)
rssCheck = feedparser.parse(url)
rssData = {}
for item in rssPR.entries:
rssData[item.link] = "{}\n{}\n{}\{}\n".format(item.title, item.author, item.published, item.summary)
feed = {}
fluff=0
for i in rssData:
entry = rssData[i]
ihash=hashlib.md5(entry.encode())
feed.update({ihash.hexdigest():entry})
fluff=fluff+1
hashin = open('/Users/grichardson/hashes','r+')
newhash = ''.join(line.rstrip('\r\n') for line in hashin)
for key,value in feed.items():
if key not in newhash:
p.control('LF')
p.control('LF')
p.text(value)
p.control('LF')
p.control('LF')
hashin.write(key+'\n')
pass
else:
continue
hashin.close()