83 lines
2.9 KiB
Python
83 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
|
import os
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
import package.utils as utils
|
|
|
|
from package.config import TZ as TZ
|
|
from package.config import DB as DB
|
|
from package.hash_tags import get_top_nouns as get_top_nouns
|
|
from package.youtube.uploader import upload_video as upload_video
|
|
from package.youtube.uploader import CategoryId as CategoryId
|
|
|
|
def process_shorts():
|
|
shorts = DB.get_unuploaded_shorts()
|
|
data = DB.get_data()
|
|
( data_id, name, release_time, _, _) = data[0]
|
|
|
|
current_time = datetime.now(TZ)
|
|
release_time = datetime.strptime(release_time, "%Y-%m-%d %H:%M:%S%z")
|
|
|
|
if current_time > release_time:
|
|
pass
|
|
else:
|
|
release_time = current_time
|
|
release_time = release_time.replace(hour=12, minute=0, second=0, microsecond=0)
|
|
|
|
for short in shorts:
|
|
(
|
|
id,
|
|
title,
|
|
created_at,
|
|
view_count,
|
|
duration,
|
|
url,
|
|
thumbnail_url,
|
|
game_id,
|
|
game_name,
|
|
stream_id,
|
|
creator_name,
|
|
clip_is,
|
|
downloaded,
|
|
uploaded_yt,
|
|
uploaded_yt_chats,
|
|
uploaded_yt_shorts,
|
|
) = short
|
|
|
|
original_path = f"download/clips/{id}/{id}.mp4"
|
|
file_path = f"download/clips/{id}/{id}_gaussian_9_16.mp4"
|
|
file_csv = f"download/clips/{id}/{id}_{name}.csv"
|
|
if not os.path.exists(file_path):
|
|
file_path = f"download/clips/{id}/{id}_black_9_16.mp4"
|
|
if not os.path.exists(file_path):
|
|
continue
|
|
|
|
title = title
|
|
created_at = datetime.strptime(created_at, "%Y-%m-%d %H:%M:%S%z")
|
|
created_at = created_at.astimezone(TZ)
|
|
categoryId = CategoryId.GAMING
|
|
description = f"Game: {game_name}, Clipped By: {creator_name}, on {created_at.strftime("%Y-%m-%d %H:%M:%S %Z (%:z)")}, #Shorts #Clips #Twitch Every Friday and Sunday @7:30 ET https://twitch.tv/teampgp"
|
|
privatcyStatus = 'private'
|
|
tags = ['shorts', 'gaming', 'TeamPGP', f'{game_name}', f'{creator_name}', 'twitch_clips', 'clips', 'Level1Techs', 'twitch']
|
|
|
|
tags.extend(get_top_nouns(f"download/clips/{id}/{id}.srt"))
|
|
|
|
data_csv = []
|
|
|
|
if os.path.exists(original_path):
|
|
if video_id := upload_video(original_path, title, categoryId, description, 'unlisted', tags):
|
|
data_csv.extend(video_id, current_time)
|
|
release_time += timedelta(days=1)
|
|
if video_id := upload_video(file_path, title, categoryId, f"{description} Original Full size @ https://youtu.be/{video_id}", privatcyStatus, tags, release_time):
|
|
data_csv.extend(video_id, release_time)
|
|
DB.mark_as_uploaded_shorts(id)
|
|
utils.write_csv(data_csv, file_csv)
|
|
|
|
DB.update_date_shorts(data_id, release_time)
|
|
|
|
def process_uploads():
|
|
process_shorts()
|
|
|
|
if __name__ == "__main__":
|
|
pass |