mirror of
https://github.com/placeAtlas/atlas.git
synced 2024-11-16 15:01:44 +01:00
32 lines
898 B
Python
Executable file
32 lines
898 B
Python
Executable file
|
|
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')
|
|
|
|
startId = 1492
|
|
|
|
reddit = praw.Reddit(client_id=client_id, client_secret=client_secret, user_agent='atlas_bot')
|
|
|
|
for submission in reddit.subreddit('placeAtlas').new(limit=15):
|
|
#print(dir(submission))
|
|
if(submission.link_flair_text == "New Entry"):
|
|
text = submission.selftext
|
|
text = text.replace("\"id\": 0,", "\"id\": 0,\n\t\t\"submitted_by\": \""+submission.author.name+"\",")
|
|
|
|
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)
|
|
|
|
outfile.write(text+",")
|
|
print("written "+submission.title)
|
|
else:
|
|
print("skipped "+submission.title)
|