From efba28a7b55ac802efacbad0ba4f488c2565d62c Mon Sep 17 00:00:00 2001 From: Richard Allen Date: Thu, 16 Jul 2026 14:55:03 -0400 Subject: [PATCH] update file names, add uploader.py --- vod_clip2.py => twitch_download_clips.py | 46 ++++++++++++++++++++++-- void_id2.py => twitch_download_vod.py | 0 2 files changed, 44 insertions(+), 2 deletions(-) rename vod_clip2.py => twitch_download_clips.py (79%) rename void_id2.py => twitch_download_vod.py (100%) diff --git a/vod_clip2.py b/twitch_download_clips.py similarity index 79% rename from vod_clip2.py rename to twitch_download_clips.py index 174bd95..b30a146 100644 --- a/vod_clip2.py +++ b/twitch_download_clips.py @@ -4,6 +4,9 @@ import sqlite3 import subprocess from datetime import datetime +import uploader +from uploader import CategoryId + CHANNEL_NAME = 'teampgp' # Replace with the streamer's username # Stores data locally @@ -52,10 +55,33 @@ def download_clips(): print(f"Slug: {slug} | Was successfully downloaded.") mark_as_downloaded(slug) else: - print(f"Slug: {slug} | Process failed.") - + print(f"Slug: {slug} | Download Process failed.") + print("Finished Downloading Clips...") +def upload_clips(): + """Loops over the downloaded videos entries and uploaded them to youtube.""" + print("Uploading Clips...") + + unpuloaded_clips = get_unuploaded_clips() + + for slug, record_date, title, game_name, clip_by, views, downloaded, uploaded_yt in unpuloaded_clips: + print(f"Slug: {slug} | Date: {record_date} | Game: {game_name} | By: {clip_by} | Views: {views} | Title: {title}") + + file_path = f"save/clips/{slug}/{slug}.mp4" + title = title + description = f"Game: {game_name}, Cliped By: {clip_by}, on {record_date}" + categoryId = CategoryId.SHORTS + privatcyStatus = 'private' + tags = ['#SHORT', '#GAMING', '#TeamPGP', f'#{game_name}', f'#{clip_by}'] + + if (uploader.upload_video(file_path, title, description, categoryId, privatcyStatus, tags) is True): + print(f"Slug: {slug} | Was successfully uploaded.") + + mark_as_uploaded(slug) + else: + print(f"Slug: {slug} | Upload Process failed.") + def run_linux_command(command: str): """Executes a Linux command, waits for completion, and returns output.""" try: @@ -65,6 +91,14 @@ def run_linux_command(command: str): return {"success": True, "stdout": result.stdout, "stderr": result.stderr} except subprocess.CalledProcessError as e: return {"success": False, "stdout": e.stdout, "stderr": e.stderr} + +def mark_as_uploaded(slug: str): + """Flags a specific clip row record to uploaded (1).""" + CURSOR.execute( + "UPDATE clips SET uploaded_yt = 1 WHERE slug = ?", + (slug,) + ) + CONN.commit() def mark_as_downloaded(slug: str): """Flags a specific clip row record to downloaded (1).""" @@ -74,6 +108,13 @@ def mark_as_downloaded(slug: str): ) CONN.commit() +def get_unuploaded_clips(): + """Retrieves all clip rows remaining to be uploaded.""" + CURSOR.execute( + "SELECT slug, date, title, gamename, clip_by, view_count, downloaded, uploaded_yt FROM clips WHERE downloaded = 1 AND uploaded_yt = 0" + ) + return CURSOR.fetchall() + def get_undownloaded_clips(): """Retrieves all clip rows remaining to be captured.""" CURSOR.execute( @@ -187,4 +228,5 @@ if __name__ == "__main__": create_database() get_channel_clips(CHANNEL_NAME) download_clips() + upload_clips() close_database() \ No newline at end of file diff --git a/void_id2.py b/twitch_download_vod.py similarity index 100% rename from void_id2.py rename to twitch_download_vod.py