-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathr2c.py
123 lines (91 loc) · 3.33 KB
/
r2c.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import math
from reddit.parser import getThreads
from tts.tts import SpeechEngine
from tts.voices import GTTS
import math
from reddit.screenshots import downloadScreenshots
from video.background import cutbg
from video.make import makevideo
from utils.cleaning import cleanup, clearTerminal
from uploaders.insta import InstagramUploader
from utils.accounts import loadDB, saveDB
from utils.menu import menu, logo, serviceSelector
import time
import random
def text2mp3(r_obj):
to_mp3 = SpeechEngine(GTTS, r_obj)
return to_mp3.run()
def main(sub, doneVids=[]):
gt = getThreads(sub, doneVids)
infos, doneVids = gt["infos"], gt["doneVideos"]
print(f"[{i}] Thread grabbed: {infos['title']}")
a = text2mp3(infos)
length, count = math.ceil(a["length"]), a["idx"]
downloadScreenshots(infos, count)
cutbg(length)
vidP = makevideo(count, length, infos, sub)
cleanup()
ig = InstagramUploader("idevfazt3stes", "Yoqu1201")
ig.upload(vidP, ["askreddit", "quesiton", "reddit"])
return doneVids
def r2c_ig(account, sub, i):
doneVids = account["doneVids"]
gt = getThreads(sub, doneVids)
infos, doneVids = gt["infos"], gt["doneVideos"]
print(f"[{i}] Thread grabbed: {infos['title']}")
a = text2mp3(infos)
length, count = math.ceil(a["length"]), a["idx"]
downloadScreenshots(infos, count)
print(f"[{i}] Screenshots downloaded")
cutbg(length)
print(f"[{i}] Background cut")
vidP = makevideo(count, length, infos, sub)
cleanup()
print(f"[{i}] Uploading...")
ig = InstagramUploader(account["username"], account["password"])
ig.upload(vidP, account["tags"])
print(f"[{i}] Uploaded\n")
accs = loadDB()
for acc in accs["instagram"]:
if acc["username"] == account["username"] and acc["password"] == account["password"]:
acc["doneVids"] = doneVids
saveDB(accs)
if __name__ == "__main__":
menu()
clearTerminal()
logo()
service = serviceSelector()
timer = int(input("Choose sleep time between posts (in minutes): ")) * 60
accs = loadDB()
i = 1
if service != "makevideo":
while True:
for acc in accs[service]:
if acc["enabled"] == "True":
sub = random.choice(acc["subs"])
print(f'[{i}] in {acc["username"]} from {sub}')
r2c_ig(acc, sub, i)
print(f"Sleeping for {timer / 60} minutes")
i += 1
time.sleep(timer)
else:
subs = input("Enter subreddits separated by commas: ").split(" ")
while True:
sub = random.choice(subs)
print(f'[{i}] in {sub}')
acs = loadDB()
doneVids = acs["doneNone"]
gt = getThreads(sub, doneVids)
infos, doneVids = gt["infos"], gt["doneVideos"]
print(f"[{i}] Thread grabbed: {infos['title']}")
a = text2mp3(infos)
length, count = math.ceil(a["length"]), a["idx"]
downloadScreenshots(infos, count)
print(f"[{i}] Screenshots downloaded")
cutbg(length)
print(f"[{i}] Background cut")
vidP = makevideo(count, length, infos, sub)
cleanup()
print(f"[{i}] Video created")
acs["doneVids"] = doneVids
saveDB(acs)