Created
October 19, 2013 04:40
-
-
Save anonymous/7051718 to your computer and use it in GitHub Desktop.
/u/mdadmfan's raop hax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime as dt | |
import json | |
import random | |
import re | |
import requests as req | |
today = dt.datetime.today() | |
# these users were validated by hand | |
extraEntries = ["could be you"] | |
commentsReq = req.get("http://www.reddit.com/r/Random_Acts_Of_Pizza/comments/1ordny/content_random_pizza.json") | |
comments = json.loads(commentsReq.text)[1]["data"]["children"] | |
entries = dict() | |
for comment in comments: | |
comment = comment["data"] | |
if re.match("(?i).*random pizza.*",comment["body"]) and "reddit_status" not in comment["author"]: | |
user = json.loads(req.get("http://www.reddit.com/user/" + comment["author"] + "/about.json").text)["data"] | |
age_in_days = (today - dt.datetime.fromtimestamp(user["created"])).days | |
print "%-20s\t%-7s\t%s" % (str(comment["author"]),str(user["has_verified_email"]),str(age_in_days)) | |
if user["has_verified_email"] and age_in_days > 31: | |
entries[str(comment["author"])] = 0 | |
listEntries = list(entries) | |
listEntries = listEntries + extraEntries | |
print "Entries: " + str(listEntries) | |
print "Winner: " + str(random.choice(listEntries)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment