-
Notifications
You must be signed in to change notification settings - Fork 1
/
fetchcliplink.py
31 lines (24 loc) · 1.2 KB
/
fetchcliplink.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
from writelink import writelink
import praw
#fetches 1 clip thats above 1000 upvotes; return type = list
def fetchcliplink(links, SUBREDDIT = "LivestreamFail"):
reddit = praw.Reddit(client_id='VZkMdSXZhyy-ow', client_secret='', user_agent='mainBot')
subreddit = reddit.subreddit(SUBREDDIT)
for post in subreddit.top("day"):#, limit = 5):
postchannel = (str(post.link_flair_text).lower()[9:])
# to take channel name from post via the flair, removing the excess part by checking spaces
for i in range(0, len(postchannel)):
#print (i)
if postchannel[i] == " ":
postchannel = postchannel[:i]
break
#print(postchannel+ " "+ str(post.score)+ "upvotes")
try:
if ((post.url).startswith("https://clips.twitch.tv") and post.score >= 1000 and post.url not in links["url"]):
#print(postchannel)
dic = {"url": [], "time": [], "title": []}
dic["url"], dic["time"], dic["title"] = post.url, post.created_utc, post.title
return dic
except:
return (None)
#fetchcliplink()