2017-04-04 20:12:45 +02:00
|
|
|
|
|
|
|
import praw
|
|
|
|
|
|
|
|
outfile = open('temp.js', 'w')
|
|
|
|
|
|
|
|
credentials = open('credentials', 'r')
|
|
|
|
client_id = credentials.readline().strip(' \t\n\r')
|
|
|
|
client_secret = credentials.readline().strip(' \t\n\r')
|
|
|
|
|
2017-05-01 17:54:19 +02:00
|
|
|
startId = 1778
|
2017-04-04 20:12:45 +02:00
|
|
|
|
|
|
|
reddit = praw.Reddit(client_id=client_id, client_secret=client_secret, user_agent='atlas_bot')
|
|
|
|
|
2017-05-01 17:54:19 +02:00
|
|
|
for submission in reddit.subreddit('placeAtlas').new(limit=220):
|
2017-04-05 01:08:21 +02:00
|
|
|
#print(dir(submission))
|
2017-04-04 20:12:45 +02:00
|
|
|
if(submission.link_flair_text == "New Entry"):
|
|
|
|
text = submission.selftext
|
2017-04-05 01:08:21 +02:00
|
|
|
text = text.replace("\"id\": 0,", "\"id\": 0,\n\t\t\"submitted_by\": \""+submission.author.name+"\",")
|
2017-04-05 02:53:39 +02:00
|
|
|
|
|
|
|
lines = text.split("\n")
|
|
|
|
|
|
|
|
for i, line in enumerate(lines):
|
|
|
|
if("\"id\": 0" in line):
|
|
|
|
lines[i] = line.replace("\"id\": 0", "\"id\": "+str(startId))
|
|
|
|
startId = startId + 1
|
|
|
|
|
|
|
|
text = "\n".join(lines)
|
2017-04-05 01:08:21 +02:00
|
|
|
|
2017-04-04 20:12:45 +02:00
|
|
|
outfile.write(text+",")
|
|
|
|
print("written "+submission.title)
|
|
|
|
else:
|
|
|
|
print("skipped "+submission.title)
|