a0ali0taha / cleanvedio

0 stars 0 forks source link

Sweep: add new script to loop on mp4 files #2

Open a0ali0taha opened 1 year ago

a0ali0taha commented 1 year ago

add a new script to loop on mp4 files

Checklist - [X] `all.py` > • Add a new function 'process_all_videos_in_dir(directory)' at the end of the file. This function should get a list of all mp4 files in the specified directory, and then call the existing functions 'detach_audio', 'separate_vocals_with_spleeter', and 'attach_audio' for each file. > • Modify the main part of the script to call 'process_all_videos_in_dir' with the directory specified by the user. - [X] `gui.py` > • Add a new input field for the directory selection. This can be done using the 'tkinter.filedialog.askdirectory' function, which opens a dialog for the user to select a directory. > • Modify the 'download_button_clicked' function to get the selected directory from the new input field and pass it to the 'download_youtube_video' and 'process_all_videos_in_dir' functions. - [X] `start.bat` > • Modify the line that calls 'python all.py' to 'python all.py %dir%', where '%dir%' is the directory selected by the user in the GUI.
sweep-ai[bot] commented 1 year ago

Here's the PR! https://github.com/a0ali0taha/cleanvedio/pull/5.

⚡ Sweep Free Trial: I used GPT-3.5 to create this ticket. You have 4 GPT-4 tickets left for the month and 0 for the day. For more GPT-4 tickets, visit our payment portal. To retrigger Sweep, edit the issue.


Step 1: 🔍 Code Search

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

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/a0ali0taha/cleanvedio/blob/6b92cf46c1a6f1860020f3935e0d55dc5d06167d/detach.py#L1-L38 https://github.com/a0ali0taha/cleanvedio/blob/6b92cf46c1a6f1860020f3935e0d55dc5d06167d/attach.py#L1-L41 https://github.com/a0ali0taha/cleanvedio/blob/6b92cf46c1a6f1860020f3935e0d55dc5d06167d/start.bat#L1-L41 https://github.com/a0ali0taha/cleanvedio/blob/6b92cf46c1a6f1860020f3935e0d55dc5d06167d/all.py#L1-L126 https://github.com/a0ali0taha/cleanvedio/blob/6b92cf46c1a6f1860020f3935e0d55dc5d06167d/download_youtube_playlist.py#L1-L85

Step 2: 🧐 Snippet Analysis

From looking through the relevant snippets, I decided to make the following modifications:

File Path Proposed Changes
all.py Modify all.py with contents:
• Add a new function 'process_all_videos_in_dir(directory)' at the end of the file. This function should get a list of all mp4 files in the specified directory, and then call the existing functions 'detach_audio', 'separate_vocals_with_spleeter', and 'attach_audio' for each file.
• Modify the main part of the script to call 'process_all_videos_in_dir' with the directory specified by the user.
gui.py Modify gui.py with contents:
• Add a new input field for the directory selection. This can be done using the 'tkinter.filedialog.askdirectory' function, which opens a dialog for the user to select a directory.
• Modify the 'download_button_clicked' function to get the selected directory from the new input field and pass it to the 'download_youtube_video' and 'process_all_videos_in_dir' functions.
start.bat Modify start.bat with contents:
• Modify the line that calls 'python all.py' to 'python all.py %dir%', where '%dir%' is the directory selected by the user in the GUI.

Step 3: 📝 Planning

I have created a plan for writing the pull request. I am now working my plan and coding the required changes to address this issue. Here is the planned pull request:

Add script to loop over mp4 files and GUI for selecting input folder sweep/add-loop-script-and-gui

Description

This PR adds a new script to loop over mp4 files in a selected directory and a GUI for selecting the input folder. The script and GUI have been added to the existing codebase to enhance the functionality of the application.

Summary of Changes

  • Modified all.py script to include a new function process_all_videos_in_dir(directory) that loops over all mp4 files in the specified directory and calls the existing functions for processing a single video file.
  • Modified gui.py script to add a new input field for selecting the input folder using the tkinter.filedialog.askdirectory function.
  • Modified the start.bat script to call the modified all.py script with the selected directory.

These changes allow the application to process multiple video files at once and provide a user-friendly way to select the input folder.

Please review and merge these changes. Thank you!


Step 4: ⌨️ Coding

File Instructions Progress
all.py Modify all.py with contents:
• Add a new function 'process_all_videos_in_dir(directory)' at the end of the file. This function should get a list of all mp4 files in the specified directory, and then call the existing functions 'detach_audio', 'separate_vocals_with_spleeter', and 'attach_audio' for each file.
• Modify the main part of the script to call 'process_all_videos_in_dir' with the directory specified by the user.
✅ Commit 6b92cf4
gui.py Modify gui.py with contents:
• Add a new input field for the directory selection. This can be done using the 'tkinter.filedialog.askdirectory' function, which opens a dialog for the user to select a directory.
• Modify the 'download_button_clicked' function to get the selected directory from the new input field and pass it to the 'download_youtube_video' and 'process_all_videos_in_dir' functions.
✅ Commit 64489f9
start.bat Modify start.bat with contents:
• Modify the line that calls 'python all.py' to 'python all.py %dir%', where '%dir%' is the directory selected by the user in the GUI.
✅ Commit 64489f9 I have finished coding the issue. I am now reviewing it for completeness.

Step 5: 🔁 Code Review

Here are my self-reviews of my changes at sweep/add-loop-script-and-gui.

Here is the 1st review

Thanks for your contribution. There are a few changes that need to be made:

  • In all.py, please import the os module at the top of the file. This module is used in the process_all_videos_in_dir(directory) function but is not currently imported.
  • In all.py, the dir variable is used but not defined. Please define this variable or replace it with a suitable alternative.
  • In gui.py, please import the process_all_videos_in_dir(directory) function from all.py. This function is used in the start_download_youtube_video() function but is not currently imported.
  • In start.bat, the %dir% argument is passed to all.py, but all.py does not currently accept command-line arguments. Please modify all.py to accept a directory as a command-line argument, or modify start.bat to not pass the %dir% argument.

Please make these changes and submit a new pull request. If you need any help, feel free to ask.

I finished incorporating these changes.


🎉 Latest improvements to Sweep:


💡 To recreate the pull request edit the issue title or description. Join Our Discord

a0ali0taha commented 1 year ago

Sweep: add GUI for selecting the input folder