Skip to content
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

added back simple format selection to youtube-downloader & show advanced options. #17176

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions extensions/youtube-downloader/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# YouTube Downloader Changelog

## [Add audio and video format selection] - {PR_MERGE_DATE}

- Add show advanced options checkbox
- Add audio and video format selection

## [Improvement] - 2025-02-17

- Add an experimental preference option for forcing IPv4 to solve some network issues
Expand Down
3 changes: 2 additions & 1 deletion extensions/youtube-downloader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"ridemountainpig",
"xmorse",
"litomore",
"anwarulislam"
"anwarulislam",
"kickthedragon"
],
"categories": [
"Applications",
Expand Down
36 changes: 34 additions & 2 deletions extensions/youtube-downloader/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import { DownloadOptions, isValidHHMM, isYouTubeURL, parseHHMM, preferences } fr

export default function DownloadVideo() {
const [error, setError] = useState(0);

const [showAdvancedOptions, setShowAdvancedOptions] = useState(false);
const [selectedFormat, setSelectedFormat] = useState<string>("");
const audioFormats = ["mp3", "wav", "aac", "flac", "ogg"];
const { handleSubmit, values, itemProps, setValue, setValidationError } = useForm<DownloadOptions>({
initialValues: {
url: "",
Expand All @@ -32,7 +34,15 @@ export default function DownloadVideo() {

options.push("--ffmpeg-location", preferences.ffmpegPath);
options.push("-f", "bv*[ext=mp4][vcodec^=avc]+ba[ext=m4a]/b[ext=mp4]");

if (selectedFormat) {
if (audioFormats.includes(selectedFormat)) {
options.push("--extract-audio");
options.push("--audio-format", selectedFormat);
} else {
options.push("--recode-video", selectedFormat);
}
options.push("--no-keep-video");
}
// if (!values.startTime && values.endTime) {
// options.push("--download-sections");
// options.push(`*0:00-${values.endTime}`);
Expand Down Expand Up @@ -258,6 +268,28 @@ export default function DownloadVideo() {
placeholder="https://www.youtube.com/watch?v=xRMPKQweySE"
{...itemProps.url}
/>
<Form.Checkbox id="advanced-options" label="Show advanced options" onChange={setShowAdvancedOptions} />
{showAdvancedOptions && (
<Form.Dropdown id="format" title="Format" value="{selectedFormat}" onChange={setSelectedFormat}>
<Form.Dropdown.Item value="" title="Select Format..." />
<Form.Dropdown.Section title="Audio">
<Form.Dropdown.Item value="mp3" title="MP3" />
<Form.Dropdown.Item value="wav" title="WAV" />
<Form.Dropdown.Item value="aac" title="AAC" />
<Form.Dropdown.Item value="flac" title="FLAC" />
<Form.Dropdown.Item value="ogg" title="OGG" />
</Form.Dropdown.Section>
<Form.Dropdown.Section title="Video">
<Form.Dropdown.Item value="avi" title="AVI" />
<Form.Dropdown.Item value="flv" title="FLV" />
<Form.Dropdown.Item value="gif" title="GIF" />
<Form.Dropdown.Item value="mkv" title="MKV" />
<Form.Dropdown.Item value="mov" title="MOV" />
<Form.Dropdown.Item value="mp4" title="MP4" />
<Form.Dropdown.Item value="webm" title="WebM" />
</Form.Dropdown.Section>
</Form.Dropdown>
)}
{/*<Form.Separator />*/}
{/*<Form.TextField*/}
{/* info="Optional. Specify when the output video should start. Follow the format HH:MM:SS or MM:SS."*/}
Expand Down
Loading