feat: implement YouTube downloader UI and integration logic with renderer, CSS, and main process support
This commit is contained in:
+6
-4
@@ -206,27 +206,29 @@ function getVideoInfo(url) {
|
||||
}
|
||||
|
||||
// Download video or convert to MP3
|
||||
function downloadMedia(url, format, outputDir, onProgress) {
|
||||
console.log(`[DEBUG] Media download requested. Format: ${format}, Target Dir: ${outputDir}`);
|
||||
function downloadMedia(url, format, quality, outputDir, onProgress) {
|
||||
console.log(`[DEBUG] Media download requested. Format: ${format}, Quality: ${quality}, Target Dir: ${outputDir}`);
|
||||
return new Promise((resolve, reject) => {
|
||||
let args = [];
|
||||
const outputTemplate = path.join(outputDir, '%(title)s.%(ext)s');
|
||||
|
||||
if (format === 'mp3') {
|
||||
const q = quality ? `${quality}K` : '320K'; // '320K', '256K', '192K'
|
||||
args = [
|
||||
'--no-playlist',
|
||||
'--ffmpeg-location', FFMPEG_PATH,
|
||||
'-x',
|
||||
'--audio-format', 'mp3',
|
||||
'--audio-quality', '320K',
|
||||
'--audio-quality', q,
|
||||
'-o', outputTemplate,
|
||||
url
|
||||
];
|
||||
} else {
|
||||
const res = quality || '1080'; // '1080', '720', '480'
|
||||
args = [
|
||||
'--no-playlist',
|
||||
'--ffmpeg-location', FFMPEG_PATH,
|
||||
'-f', 'bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4] / bv*+ba/b',
|
||||
'-f', `bv*[height<=${res}][ext=mp4]+ba[ext=m4a]/b[height<=${res}][ext=mp4] / bv*[height<=${res}]+ba/b[height<=${res}]`,
|
||||
'-o', outputTemplate,
|
||||
url
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user