update uploading functions

This commit is contained in:
SumGuyV5 committed 2026-09-19 00:05:54 +00:00
1 parent 61fe9eca25
commit d4db0b04a4
9 files changed
+85 -55

No files matched your search

+43 -40
View File
@@ -11,73 +11,76 @@ 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
from package.database import TwitchVideo, YoutubeInfo, Data
def process_shorts():
shorts = DB.get_unuploaded_shorts()
data = DB.get_data()
( data_id, name, release_time, _, _) = data[0]
meta_data: Data = data[0]
release_time = meta_data.date_shorts
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"
original_path = f"download/clips/{short.id}/{short.id}.mp4"
file_path = f"download/clips/{short.id}/{short.id}_gaussian_9_16.mp4"
file_csv = f"download/clips/{short.id}/{short.id}_{meta_data.name}.csv"
if not os.path.exists(file_path):
file_path = f"download/clips/{id}/{id}_black_9_16.mp4"
file_path = f"download/clips/{short.id}/{short.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")
short.title = short.title
created_at = datetime.strptime(short.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"
description = f"Game: {short.game_name}, Clipped By: {short.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 = ['shorts', 'gaming', 'TeamPGP', f'{short.game_name}', f'{short.creator_name}', 'twitch_clips', 'clips', 'Level1Techs', 'twitch']
tags.extend(get_top_nouns(f"download/clips/{id}/{id}.srt"))
tags.extend(get_top_nouns(f"download/clips/{short.id}/{short.id}.srt"))
data_csv = []
youtube_info = DB.get_youtube_info(short.id)
if not youtube_info:
youtube_info = YoutubeInfo()
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)
if yt_video_id := upload_video(original_path, short.title, categoryId, description, 'unlisted', tags):
data_csv = [yt_video_id, current_time]
release_time += timedelta(days=1)
DB.update_date_shorts(data_id, release_time)
# Assign / Update values on the object
youtube_info.id = short.id
youtube_info.yt_id = yt_video_id
youtube_info.yt_date = datetime.now(TZ)
if yt_video_id := upload_video(file_path, short.title, categoryId, f"{description} Original Full size @ https://youtu.be/{yt_video_id}", privatcyStatus, tags, release_time):
data_csv.extend([yt_video_id, release_time])
DB.mark_as_uploaded_shorts(short.id)
DB.mark_as_uploaded_yt(short.id)
utils.write_csv([data_csv], file_csv)
youtube_info.yt_short_id = yt_video_id
youtube_info.yt_short_date = datetime.now(TZ)
DB.insert(youtube_info)
DB.update_date_shorts(meta_data.id, release_time)
def process_chats():
pass
def process_uploads():
process_shorts()
process_chats()
if __name__ == "__main__":
pass