From c8d645e9bd8d91e18296f96f5bb8e5b52e05532b Mon Sep 17 00:00:00 2001 From: SumGuyV5 Date: Wed, 22 Jul 2026 00:42:03 +0000 Subject: [PATCH] update launch.json and remove old code from youtube_short --- .vscode/launch.json | 5 +-- youtube_short.py | 91 --------------------------------------------- 2 files changed, 1 insertion(+), 95 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 20292ec..148f8b7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,10 +9,7 @@ "type": "debugpy", "request": "launch", "program": "${file}", - "args": [ - "--convert", - "/home/richard/downloader/save/clips/VibrantKathishLobsterPunchTrees/VibrantKathishLobsterPunchTrees.mp4" - ] + "args": [] } ] } \ No newline at end of file diff --git a/youtube_short.py b/youtube_short.py index cc07f77..c975ac5 100644 --- a/youtube_short.py +++ b/youtube_short.py @@ -128,97 +128,6 @@ def fit_to_9_16_letterbox(input_path: str, top_text: str = "TOP TEXT", bottom_te print(f"🎉 Text overlay video saved to: {output_path}") -def convert_to_short(input_path: str): - input_file = Path(input_path) - - # Generate paths using pathlib - sanitized_input_path = input_file.parent / f"{input_file.stem}_clean{input_file.suffix}" - output_path = input_file.parent / f"{input_file.stem}_shorts{input_file.suffix}" - - print("Sanitizing video metadata for MoviePy parser...") - cleanup_cmd = [ - "ffmpeg", "-y", "-i", str(input_file), - "-map_chapters", "-1", "-sn", - "-c", "copy", str(sanitized_input_path) - ] - subprocess.run(cleanup_cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - - # Load the sanitized video file - clip = VideoFileClip(str(sanitized_input_path)) - - # 1. Check video duration - if clip.duration >= 60: - print(f"❌ Error: Video is {clip.duration:.2f}s long. It must be under 60 seconds.") - clip.close() - if sanitized_input_path.exists(): - sanitized_input_path.unlink() - return False - - print(f"✅ Video length check passed ({clip.duration:.2f}s). Processing...") - - # 2. Calculate the target width for a 9:16 aspect ratio based on height - target_height = clip.h - target_width = int(target_height * (9 / 16)) - - # 3. FIX FOR v2.x: Use native .cropped() method directly on the clip - print("🎬 Cropping video to 9:16 vertical view...") - short_clip = clip.cropped( - width=target_width, - height=target_height, - x_center=clip.w / 2, - y_center=clip.h / 2 - ) - - # 4. FIX FOR v2.x: Use native .resized() method directly on the clip - if short_clip.h != 1920: - print("📐 Resizing frame resolution to standard 1080x1920 Shorts format...") - short_clip = short_clip.resized(new_size=(1080, 1920)) - - # 5. Export the final video file - short_clip.write_videofile( - str(output_path), - codec="libx264", - audio_codec="aac", - fps=clip.fps - ) - - # Clean up files and close streams - clip.close() - short_clip.close() - - if sanitized_input_path.exists(): - sanitized_input_path.unlink() - - print(f"🎉 Success! Short saved as: {output_path}") - return True - - -def upload_shorts(): - """Loops over the downloaded videos entries and uploaded them to youtube.""" - print("Uploading Shorts...") - - unuploaded_shorts = DB.get_unuploaded() - - categoryId = CategoryId.GAMING - - for slug, record_date, title, game_name, clip_by, views, downloaded, uploaded_yt in unuploaded_shorts: - print(f"Slug: {slug} | Date: {record_date} | Game: {game_name} | By: {clip_by} | Views: {views} | Title: {title}") - - file_path = f"save/clips/{slug}/{slug}_shorts.mp4" - title = title - description = f"Game: {game_name}, Cliped By: {clip_by}, on {record_date}, #Shorts #Clips #Twitch Every Friday and Sunday @7:30 EST https://twitch.tv/teampgp" - categoryId = CategoryId.GAMING - privatcyStatus = 'private' - tags = ['shorts', 'gaming', 'TeamPGP', f'{game_name}', f'{clip_by}', 'twitch_clips', 'clips', 'Level1Techs', 'twitch'] - - output = uploader.upload_video(file_path, title, categoryId, description, privatcyStatus, tags) - - if output is True: - print(f"Slug: {slug} | Was successfully uploaded.") - DB.mark_as_uploaded(slug) - else: - print(f"Slug: {slug} | Upload Process failed.") - def main(): # Set up the command-line argument parser parser = argparse.ArgumentParser(description="TeamPGP Clip Processing and Upload Pipeline")