-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
58 lines (44 loc) · 1.4 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
import os
import datetime
import random
from logger import Logger
from description import get_title, get_description
from youtube_upload import upload_video
import download
import video_processing
from data import MUSIC_URLS, URLS
UPLOADED_DIR = 'uploaded'
def main():
Logger.log('Started. Creating dirs.')
os.makedirs(download.DOWNLOAD_DIR, exist_ok=True)
os.makedirs(UPLOADED_DIR, exist_ok=True)
os.system('rm {}'.format(os.path.join(download.DOWNLOAD_DIR, '*')))
video_name = '{}-{}.mp4'.format(datetime.date.today().isoformat(), random.randint(0, 10000))
video_name = os.path.join(UPLOADED_DIR, video_name)
sources = {}
for subreddit in URLS:
more_sources = download.get_posts_and_download(subreddit)
for (key, value) in more_sources.items():
sources[key] = value
music_name = 'music.m4a'
music_name = os.path.join(download.DOWNLOAD_DIR, music_name)
music_url, music_desc = random.choice(MUSIC_URLS)
download.download_music(
music_url, music_name
)
sources_list = video_processing.create_video(
download.DOWNLOAD_DIR,
music_name,
video_name,
sources
)
Logger.log(f'Created video {video_name}')
upload_video(
video_name,
get_title(),
get_description(sources_list, music_desc),
'Comedy',
'Funny'
)
if __name__ == '__main__':
main()