-
Notifications
You must be signed in to change notification settings - Fork 13
/
reddit.py
47 lines (32 loc) · 1.59 KB
/
reddit.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
38
39
40
41
42
43
44
45
46
47
from moviepy.editor import *
import datetime as dt
import pandas as pd
import praw
def comment_html(username, content):
str = "<!DOCTYPE html><html><head>" \
"<style>body {background-color: rgb(26, 26, 27);color: white;font-family: BentonSans, sans-serif;}.username {color: rgb(79, 188, 255);}.content {padding: 5px}.header {padding: 0 0 0 5px}</style>" \
"</head>" \
"<body><div><div class = 'header'><span class=username>"+username + \
"</span></div><div class = 'content'>" + content + "</div></div></body></html>"
return str
def gen_comment_image(username, content, save_path):
imgkit.from_string(comment_html(
'kindeep', 'asdfasdfafg asgdfasdf sadgasdfewher sehagdsf'), save_path)
print("Subscribe or i'll end humanity.")
with open('reddit_secret.json') as f:
secret = json.load(f)
reddit = praw.Reddit(client_id=secret['client_id'],
client_secret=secret['client_secret'],
user_agent=secret['user_agent'])
# print(reddit.read_only)
for a_subreddit in reddit.subreddits.popular(limit=1):
print(a_subreddit.display_name, '\n' +
('=' * len(a_subreddit.display_name)))
for submission in a_subreddit.top(limit=10):
print(submission.title, '\n')
gen_comment_image("kindeep", "something", "media/test.png")
img_clip = ImageClip("media/test.png").set_duration(10)
imgs = ["media/test.png", "media/test.1.png"]
clips = [ImageClip(m).set_duration(2) for m in imgs]
concat_clip = concatenate_videoclips(clips, method="compose")
concat_clip.write_videofile("media/test.mp4", fps=24)