-
Notifications
You must be signed in to change notification settings - Fork 31
Let users download subtitles for youtube videos #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
phattantran1997
commented
May 4, 2025
- Update Download Logic for YoutubeDownloader with additional option: Subtitles' Language.
- Add new column "SubtitleLanguage" for model YoutubeDownloadQueueItem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @phattantran1997, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request by phattantran1997 introduces the functionality to download subtitles for YouTube videos. It updates the download logic for the YoutubeDownloader, adding a subtitle language option. A new column, "SubtitleLanguage", is added to the YoutubeDownloadQueueItem model to store the selected subtitle language. The UI is updated to include a checkbox to enable subtitle downloading and a dropdown to select the desired language.
Highlights
- New Feature: Subtitle Download: Adds the ability to download subtitles along with YouTube videos.
- UI Enhancement: Introduces a checkbox and dropdown in the UI to control subtitle downloading and language selection.
- Model Update: Adds a 'SubtitleLanguage' property to the 'YoutubeDownloadQueueItem' model.
- Backend Logic: Modifies the YoutubeDownloadQueueService and YtdlpService to handle subtitle downloading based on user selection.
Changelog
Click here to see the changelog
- SaveHere/SaveHere/Components/Download/DownloadVideoAudio.razor
- Added a MudStack containing a MudCheckBox for enabling subtitle download and a MudSelect for choosing the subtitle language.
- The MudSelect is disabled when the subtitle download checkbox is unchecked.
- SaveHere/SaveHere/Components/Utility/SpotifySearch.razor
- Modified the call to
YoutubeDownloadQueueService.AddQueueItemAsyncto passnullfor thesubtitleLanguageparameter.
- Modified the call to
- SaveHere/SaveHere/Models/YoutubeDownloadQueueItem.cs
- Added a
SubtitleLanguageproperty of typestring?with a default value of "en".
- Added a
- SaveHere/SaveHere/Services/YoutubeDownloadQueueService.cs
- Modified the
AddQueueItemAsyncmethod to accept asubtitleLanguageparameter. - Updated the
AddQueueItemAsyncmethod to set theSubtitleLanguageproperty of theYoutubeDownloadQueueItem. - Modified the
StartDownloadAsyncmethod to pass theSubtitleLanguageto the_ytdlpService.DownloadVideomethod.
- Modified the
- SaveHere/SaveHere/Services/YtdlpService.cs
- Modified the
DownloadVideomethod to accept asubtitleLanguageparameter. - Added logic to construct subtitle-related arguments for the youtube-dlp command based on the
subtitleLanguageparameter. - Included the subtitle arguments in the final youtube-dlp command.
- Modified the
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A download's quest,
Subtitles appear at best,
Words dance on the screen.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces the functionality to download subtitles for YouTube videos, enhancing the application's capabilities. The changes involve adding a new UI element for subtitle selection, updating the data model, and modifying the download logic to include subtitle options. Overall, the implementation seems well-structured, but there are a few areas that could be improved.
Summary of Findings
- Missing Input Validation: The
_subtitleLanguagefield is directly passed to the yt-dlp command without any validation. This could lead to command injection vulnerabilities if a malicious user inputs a crafted string. Input validation is crucial to ensure the application's security. - Hardcoded Subtitle Languages: The subtitle languages are hardcoded in the UI. It would be better to fetch these languages dynamically from yt-dlp or a configuration file to allow for more flexibility and easier updates.
- Error Handling: There is no specific error handling for subtitle downloads. If the subtitle download fails, the user might not be notified, or the download process might be interrupted. Proper error handling is essential for a smooth user experience.
Merge Readiness
While the pull request introduces a valuable feature, there are some concerns that need to be addressed before merging. Specifically, the lack of input validation for the subtitle language poses a security risk. Additionally, the hardcoded subtitle languages and missing error handling could lead to a less-than-ideal user experience. I recommend addressing these issues before merging. I am unable to approve this pull request, and others should review and approve this code before merging.
| string subtitleArgs = ""; | ||
| if (!string.IsNullOrWhiteSpace(subtitleLanguage)) | ||
| { | ||
| subtitleArgs = $"--write-sub --write-auto-sub --sub-lang \"{subtitleLanguage}\""; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The subtitleLanguage variable is directly embedded into the command line arguments without any validation. This could lead to command injection vulnerabilities if a malicious user inputs a crafted string. Implement input validation to ensure that the subtitleLanguage variable only contains valid language codes or "auto".
| <MudSelect T="string" @bind-Value="_subtitleLanguage" | ||
| Label="Subtitle Language" | ||
| Variant="Variant.Outlined" | ||
| Margin="Margin.Dense" | ||
| Class="ml-4" | ||
| Disabled="@(!_downloadSubtitles)"> | ||
| <MudSelectItem Value="@("en")">English</MudSelectItem> | ||
| <MudSelectItem Value="@("vi")">Vietnamese</MudSelectItem> | ||
| <MudSelectItem Value="@("ja")">Japanese</MudSelectItem> | ||
| <MudSelectItem Value="@("auto")">Auto-detect</MudSelectItem> | ||
| </MudSelect> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (!string.IsNullOrWhiteSpace(subtitleLanguage)) | ||
| { | ||
| subtitleArgs = $"--write-sub --write-auto-sub --sub-lang \"{subtitleLanguage}\""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Quality = selectedQuality, | ||
| Proxy = proxyUrl, | ||
| DownloadFolder = downloadFolderName, | ||
| SubtitleLanguage = subtitleLanguage, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
@gudarzi can you check this PR? |