Created
January 14, 2018 19:13
-
-
Save blha303/a3f1284929834625aa8990f2794a458f to your computer and use it in GitHub Desktop.
VOD thread favorite runs megathread https://www.reddit.com/r/speedrun/comments/7qdpgr/agdq_favorite_runs_megathread_2018/
This file contains hidden or 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
#!/var/www/html/gdq/newpraw/bin/python | |
import praw, json | |
with open("/home/steven/gdqauth.json") as f: | |
auth = json.load(f) | |
r = praw.Reddit(user_agent='GDQ thread autoupdater by /u/suudo', refresh_token=auth["token"], **auth["login"]) | |
with open("/var/www/html/gdq/schedule.json") as f: | |
data = json.load(f) | |
if not hasattr(__builtins__, "raw_input"): | |
raw_input = input | |
s = r.submission(raw_input("Enter submission ID: ")) | |
comments = [] | |
for d in data["schedule"]: | |
while True: | |
try: | |
_ = s.reply("""**{}** run by {} [[1]]({})""".format(d["game"], ", ".join("[{}]({})".format(k,v) for k,v in d["runners"].items()), d["vod"])) | |
except praw.exceptions.APIException: | |
traceback.print_exc() | |
continue | |
break | |
print("Posted {} {}".format(d["game"], _.id)) | |
comments.append(("**{}** run by {}".format(d["game"], ", ".join("[{}]({})".format(k,v) for k,v in d["runners"].items())), _)) | |
s.edit("Apologies for the false start before, we've fixed the issue!\r\n\r\nFind your favorite run below and upvote it!\r\n\r\n" + "\n".join("* {} [-->](https://reddit.com/r/{}/comments/{}/_/{})".format(d, s.subreddit.display_name, s.id, c.id) for d,c in comments )) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment