-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.py
186 lines (102 loc) · 3.87 KB
/
main.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
"""
YtMaker v 1.0.0
Autogenerate compilation videos,
by getting videos from Instagram
and upload it to Youtube.
"""
from youtube_upload.client import YoutubeUploader
from instagrapi import Client
from rich import print
from moviepy.editor import *
import time
import random
import os
print("\n[blue] [?] The Number of videos to be compiled ?[/blue]", end="")
NUM_OF_VIDS_USED = int(input(" "))
print("[blue] [?] The current number of videos in youtube channel ?[/blue]", end="")
VID_NUM = int(input(" ")) + 1
print("[blue] [?] The Insta username ?[/blue]", end="")
INSTA_USERNAME = input(" ")
print("[blue] [?] The Insta pwd ?[/blue]", end="")
INSTA_PWD = input(" ")
print("[blue] [?] Client ID (yt API) ?[/blue]", end="")
ci = input(" ")
print("[blue] [?] Client secret (yt API) ?[/blue]", end="")
cs = input(" ")
print("[blue] [?] Title for the videos ?[/blue]", end="")
TITLE = input(" ")
print("[blue] [?] Description for the videos ?[/blue]", end="")
DESC = input(" ")
print("[blue] [?] Tags for the videos (separate using ',') ?[/blue]", end="")
TAGS = input(" ")
print("[blue] [?] Time delay between each videos in minutes ? [/blue]", end="")
TIME_DELAY = int(input(" "))
uploader = YoutubeUploader(ci,cs)
uploader.authenticate()
def Download():
cl = Client()
cl.request_timeout = 20
cl.login(INSTA_USERNAME, INSTA_PWD)
print("[green] [+] LOGGED IN TO INSTAGRAM[\green]")
user_id = cl.user_id_from_username(INSTA_USERNAME)
z = cl.user_following(user_id)
time.sleep(4)
URLS = []
N_URLS = []
FILES = []
for e in z:
time.sleep(4+random.randint(1,60)*0.05)
medias = cl.user_medias(e, 25)
for e in medias:
if e.dict()["media_type"] == 2:
URLS.append(e.dict()["video_url"])
for e in range(0, NUM_OF_VIDS_USED):
N_URLS.append(random.choice(URLS))
for e in N_URLS:
time.sleep(5+random.randint(1,60)*0.05)
FILES.append(cl.video_download_by_url(e, str(random.randint(1000000000000000,10000000000000000000000))))
return FILES
def make_video(files):
clips = []
clips.append("intro.mp4")
for e in files:
clips.append(str(e))
# concatenating both the clips
concatenate(clips,f"videos/vid_{VID_NUM}.mp4")
def concatenate(video_clip_paths, output_path, method="compose"):
# create VideoFileClip object for each video file
clips = [VideoFileClip(c) for c in video_clip_paths]
if method == "reduce":
# calculate minimum width & height across all clips
min_height = min([c.h for c in clips])
min_width = min([c.w for c in clips])
# resize the videos to the minimum
clips = [c.resize(newsize=(min_width, min_height)) for c in clips]
# concatenate the final video
final_clip = concatenate_videoclips(clips)
elif method == "compose":
# concatenate the final video with the compose method provided by moviepy
final_clip = concatenate_videoclips(clips, method="compose")
# write the output video file
final_clip.write_videofile(output_path)
while True:
print("\n\n[green] [+] DOWNLOADING VIDEOs [/green]")
files = Download()
print("[green] [+] MAKING VIDEO [/green]")
make_video(files)
for e in files:
os.system(f"rm {e}")
print("[green] [+] UPLOADING TO YT [/green]")
options = {
"title" : f"{TITLE} - {VID_NUM}" ,
"description" : DESC,
"tags" : TAGS.split(","),
"categoryId" : "22",
"privacyStatus" : "public",
"kids" : False}
# upload video
uploader.upload(f"videos/vid_{VID_NUM}.mp4",options)
print("[dark_orange] [+] UPLOADED [/dark_orange]")
VID_NUM += 1
print(f"\n[yellow] [~] Next Upload In {TIME_DELAY} Mins[/yellow]")
time.sleep(TIME_DELAY*60)