-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
59 lines (49 loc) · 1.47 KB
/
Copy pathmain.py
File metadata and controls
59 lines (49 loc) · 1.47 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import praw
import os
import requests
from frame_to_Video import convert_frames_to_video
CLIENT_ID = os.getenv('CLIENT_ID')
CLIENT_SECRET = os.getenv('CLIENT_SECRET')
reddit = praw.Reddit(client_id = CLIENT_ID,
client_secret = CLIENT_SECRET,
user_agent = "Discord Meme Bot",
username = "fakebot3")
def get_meme_image():
subreddit = reddit.subreddit('memes')
top_5 = subreddit.top(limit = 5)
top_4 = subreddit.top(limit = 4)
top_3 = subreddit.top(limit = 3)
top_2 = subreddit.top(limit = 2)
top_1 = subreddit.top(limit = 1)
for submission in top_5:
meme_5 = submission
response = requests.get(meme_5.url)
file = open("frames/5.png", "wb")
file.write(response.content)
file.close()
for submission in top_4:
meme_4 = submission
response = requests.get(meme_4.url)
file = open("frames/4.png", "wb")
file.write(response.content)
file.close()
for submission in top_3:
meme_3 = submission
response = requests.get(meme_3.url)
file = open("frames/3.png", "wb")
file.write(response.content)
file.close()
for submission in top_2:
meme_2 = submission
response = requests.get(meme_2.url)
file = open("frames/2.png", "wb")
file.write(response.content)
file.close()
for submission in top_1:
meme_1 = submission
response = requests.get(meme_1.url)
file = open("frames/1.png", "wb")
file.write(response.content)
file.close()
#get_meme_image()
convert_frames_to_video('frames/', 'video', 1)