Bzzz666 / MoneyPrinter

Automate Creation of YouTube Shorts using MoviePy.
MIT License
0 stars 0 forks source link

Sweep: refactor codebase and optimize application structure #1

Open Bzzz666 opened 8 months ago

Bzzz666 commented 8 months ago

Project is looks like it was programmed by a kid. It need refactor and structure optimization\extension.

Checklist - [X] Create `Backend/src/video_processing.py` ✓ https://github.com/Bzzz666/MoneyPrinter/commit/73c2244c382681fbba7d701cafd135de3e465e65 [Edit](https://github.com/Bzzz666/MoneyPrinter/edit/sweep/refactor_codebase_and_optimize_applicati/Backend/src/video_processing.py) - [X] Running GitHub Actions for `Backend/src/video_processing.py` ✓ [Edit](https://github.com/Bzzz666/MoneyPrinter/edit/sweep/refactor_codebase_and_optimize_applicati/Backend/src/video_processing.py) - [X] Create `Backend/src/youtube_uploader.py` ✓ https://github.com/Bzzz666/MoneyPrinter/commit/a0e721be44fa4359256c290febadbb2eb1344cd7 [Edit](https://github.com/Bzzz666/MoneyPrinter/edit/sweep/refactor_codebase_and_optimize_applicati/Backend/src/youtube_uploader.py) - [X] Running GitHub Actions for `Backend/src/youtube_uploader.py` ✓ [Edit](https://github.com/Bzzz666/MoneyPrinter/edit/sweep/refactor_codebase_and_optimize_applicati/Backend/src/youtube_uploader.py) - [X] Modify `Backend/main.py` ✓ https://github.com/Bzzz666/MoneyPrinter/commit/7f65ade62f97a79064923d072deafc52bde32aa9 [Edit](https://github.com/Bzzz666/MoneyPrinter/edit/sweep/refactor_codebase_and_optimize_applicati/Backend/main.py#L1-L999) - [X] Running GitHub Actions for `Backend/main.py` ✓ [Edit](https://github.com/Bzzz666/MoneyPrinter/edit/sweep/refactor_codebase_and_optimize_applicati/Backend/main.py#L1-L999) - [X] Modify `README.md` ✓ https://github.com/Bzzz666/MoneyPrinter/commit/dd0d3769ab1ea20c9961fa4061edb897f358082a [Edit](https://github.com/Bzzz666/MoneyPrinter/edit/sweep/refactor_codebase_and_optimize_applicati/README.md#L24-L30) - [X] Running GitHub Actions for `README.md` ✓ [Edit](https://github.com/Bzzz666/MoneyPrinter/edit/sweep/refactor_codebase_and_optimize_applicati/README.md#L24-L30)
sweep-ai[bot] commented 8 months ago

🚀 Here's the PR! #3

See Sweep's progress at the progress dashboard!
Sweep Basic Tier: I'm using GPT-4. You have 5 GPT-4 tickets left for the month and 3 for the day. (tracking ID: f717599700)

For more GPT-4 tickets, visit our payment portal. For a one week free trial, try Sweep Pro (unlimited GPT-4 tickets).
Install Sweep Configs: Pull Request

[!TIP] I can email you next time I complete a pull request if you set up your email here!


Actions (click)

GitHub Actions✓

Here are the GitHub Actions logs prior to making any changes:

Sandbox logs for 0bd5101
Checking Backend/main.py for syntax errors... ✅ Backend/main.py has no syntax errors! 1/1 ✓
Checking Backend/main.py for syntax errors...
✅ Backend/main.py has no syntax errors!

Sandbox passed on the latest main, so sandbox checks will be enabled for this issue.


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/Bzzz666/MoneyPrinter/blob/0bd51013d5c807d5dc1fa554bb0d72791e25c507/README.md#L1-L124

Step 2: ⌨️ Coding

Ran GitHub Actions for 73c2244c382681fbba7d701cafd135de3e465e65:

Ran GitHub Actions for a0e721be44fa4359256c290febadbb2eb1344cd7:

--- 
+++ 
@@ -13,6 +13,8 @@
 from apiclient.errors import HttpError
 from flask import Flask, request, jsonify
 from moviepy.config import change_settings
+from Backend.src.video_processing import VideoProcessor
+from Backend.src.youtube_uploader import YouTubeUploader

 # Load environment variables
@@ -89,8 +91,10 @@
                 }
             )

-        voice = data["voice"]
-        voice_prefix = voice[:2]
+        video_processor = VideoProcessor()
+        youtube_uploader = YouTubeUploader()
+        # Extract voice information from request data
+        voice = data.get('voice', 'en_us_001') # Default voice if not provided

         if not voice:
@@ -218,12 +222,11 @@
             subtitles_path = None

         # Concatenate videos
-        temp_audio = AudioFileClip(tts_path)
-        combined_video_path = combine_videos(video_paths, temp_audio.duration, 5, n_threads or 2)
+        combined_video_path = video_processor.combine_videos(video_paths, n_threads=n_threads or 2)

         # Put everything together
         try:
-            final_video_path = generate_video(combined_video_path, tts_path, subtitles_path, n_threads or 2, subtitles_position)
+            final_video_path = video_processor.generate_video(combined_video_path, tts_path, subtitles_path, n_threads=n_threads or 2, subtitles_position=subtitles_position)
         except Exception as e:
             print(colored(f"[-] Error generating final video: {e}", "red"))
             final_video_path = None
@@ -266,11 +269,11 @@
                 # Upload the video to YouTube
                 try:
                     # Unpack the video_metadata dictionary into individual arguments
-                    video_response = upload_video(
-                        video_path=video_metadata['video_path'],
+                    video_response = youtube_uploader.upload_video(
+                        video_file_path=video_metadata['video_path'],
                         title=video_metadata['title'],
                         description=video_metadata['description'],
-                        category=video_metadata['category'],
+                        category_id=video_metadata['category'],
                         keywords=video_metadata['keywords'],
                         privacy_status=video_metadata['privacyStatus']
                     )

Ran GitHub Actions for 7f65ade62f97a79064923d072deafc52bde32aa9:

--- 
+++ 
@@ -24,6 +24,11 @@

 # Run the backend server
 cd Backend
+# Activate the virtual environment
+source venv/bin/activate # For Linux/Mac
+venv\Scripts\activate # For Windows
+
+# Run the application
 python main.py

 # Run the frontend server

Ran GitHub Actions for dd0d3769ab1ea20c9961fa4061edb897f358082a:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/refactor_codebase_and_optimize_applicati.


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request.Something wrong? Let us know.

This is an automated message generated by Sweep AI.