forked from nang-dev/automated_youtube_channel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
48 lines (38 loc) · 1.55 KB
/
main.py
File metadata and controls
48 lines (38 loc) · 1.55 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
import logging
from scrape_tiktoks import scrape_tiktoks
from make_compilation import makeCompilation
from upload_video import upload_video
from cleanup import cleanup
import schedule
import time
import os
from googleapiclient.discovery import build
import config
hour, minute, second = str(config.NOW.hour), str(config.NOW.minute), str(config.NOW.second)
month, day, year = config.MONTH, config.NOW.day, config.NOW.year
hashtag = config.HASHTAG
OUTRO_VID = f"{config.OUTPUTPATH}"
def setup():
for path in config.PATHS:
if not os.path.exists(path): os.makedirs(path) # If path don't exist, make it
logging.info(f"Setup run at [{hour}:{minute}:{second} {month}/{day}/{year}]") #
def routine():
setup() # Step 0: Setup
scrape_tiktoks() # Step 1: Scrape Videos
makeCompilation() # Step 2: Make Compilation
upload_video() # Step 3: Upload to Youtube
cleanup() # Step 4: Cleanup
def attemptRoutine():
while True:
try: # When routine runs we stop trying to run it
routine() # If it fails, we try again in a minute
break
except OSError as err:
logging.error(f"Routine Failed on {hour}:{minute}:{second} OS error: {0}".format(err))
time.sleep(60)
DAILY_SCHEDULED_TIME = "20:00"
schedule.every().day.at(DAILY_SCHEDULED_TIME).do(attemptRoutine)
routine() # Make one video right now
while True: # and daily at the chosen time
schedule.run_pending()
time.sleep(60)