forked from hugomd/Reddit-ADN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.py
37 lines (28 loc) · 1.01 KB
/
post.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
from appdotnet import *
import praw, time
#Set a user agent, this can be your app name or a description of your app.
r = praw.Reddit(user_agent='USERAGENT')
#Obviously, put your own access token here. If you don't have a developer account, grab a token from Dev Lite, thanks @duerig
app = appdotnet(access_token="token")
already_done = set()
#Get the submissions and post them to App.net
while True:
l = r.get_top(limit=1)
submission = next(l,None)
if not submission:
continue
while submission.id in already_done:
submission=next(r.get_front_page(limit=1, params={'before':"t3_"+submission.id }),None)
if not submission:
break
if submission:
id = submission.id
title = submission.title
url = submission.short_link
if title.count > 100:
title = title[0:100] + ".."
post = title + " | " + url
app.createPost(post)
save_state = (id)
already_done.add(submission.id)
time.sleep(600)