-
Notifications
You must be signed in to change notification settings - Fork 0
/
reddit.py
46 lines (36 loc) · 1.23 KB
/
reddit.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
import sqlite3
import praw
import time
import feedparser
import os
import urlparse
#These are your variables that don't change between restarting the program
feed = 'http://modmyi.com/cydia/rsscat.php?category=Tweaks'
done = []
# Things that only need to be done once don't need to be in a function
print 'Connecting'
r = praw.Reddit(user_agent='newcydia tweaks rss bot by /u/') #put your username here to make it more unique
print 'Starting to log in!'
sub = 'newcydiatweaks'
password = ''
r.login('newcydiatweaks', password)
print 'Completed log in!'
sql = sqlite3.connect('sql.db')
log.info('Loaded SQL Database')
cur = sql.cursor()
cur.execute('CREATE TABLE IF NOT EXISTS submitted(ID TEXT)')
sql.commit()
def parseFeed():
f = feedparser.parse(feed)
for post in f.entries:
bundleid = f.link.replace('http://modmyi.com/cydia/', '')
cur.execute('SELECT * FROM submitted WHERE ID=?', [bundleid])
if not cur.fetchone():
tweakName = f.title.replace('Tweaks: ', '')
link = 'http://cydia.saurik.com/package/' + bundleid
desc = f.description
cur.execute("INSERT INTO submitted VALUES(?)", bundleid)
sql.commit()
while True:
parseFeed()
time.sleep(120)