@ -261,7 +261,7 @@ async function getInfo(url) {
// Cleaning text
// Cleaning text
getId ( "videoFormatSelect" ) . innerHTML = "" ;
getId ( "videoFormatSelect" ) . innerHTML = "" ;
getId ( "audioFormatSelect" ) . innerHTML = "" ;
getId ( "audioFormatSelect" ) . innerHTML = "" ;
getId ( "audioForVideoFormatSelect" ) . innerHTML = "" ;
getId ( "audioForVideoFormatSelect" ) . innerHTML = ` <option value="none|none">No Audio</option> ` ;
const startTime = getId ( "startTime" ) ;
const startTime = getId ( "startTime" ) ;
startTime . value = "" ;
startTime . value = "" ;
@ -488,7 +488,7 @@ async function getInfo(url) {
if (
if (
( format . video _ext !== "none" &&
( format . video _ext !== "none" &&
format . a udio_ext === "none" &&
format . a codec === "none" &&
! (
! (
format . video _ext === "mp4" &&
format . video _ext === "mp4" &&
format . vcodec &&
format . vcodec &&
@ -626,30 +626,7 @@ async function getInfo(url) {
format . audio _ext !== "none" ||
format . audio _ext !== "none" ||
( format . acodec !== "none" && format . video _ext !== "none" )
( format . acodec !== "none" && format . video _ext !== "none" )
) {
) {
let size ;
// Skip them
if ( format . filesize || format . filesize _approx ) {
size = (
Number ( format . filesize || format . filesize _approx ) /
1000000
) . toFixed ( 2 ) ;
} else {
size = i18n . _ _ ( "Unknown size" ) ;
}
const element =
"<option value='" +
( format . format _id + "|" + format . ext ) +
"'>" +
( i18n . _ _ ( format . format _note ) ||
format . resolution ||
i18n . _ _ ( "Unknown quality" ) ) +
" | " +
format . ext +
" | " +
size +
" " +
i18n . _ _ ( "MB" ) +
"</option>" ;
getId ( "videoFormatSelect" ) . innerHTML += element ;
}
}
// When there is no audio
// When there is no audio
@ -940,7 +917,7 @@ function download(
audioForVideoExt = audioForVideoValue . split ( "|" ) [ 1 ] ;
audioForVideoExt = audioForVideoValue . split ( "|" ) [ 1 ] ;
}
}
if ( ( videoExt === "mp4" && audioForVideoExt === "opus" ) || ( videoExt === "webm" && audioForVideoExt === "m4a" ) ) {
if ( ( videoExt === "mp4" && audioForVideoExt === "opus" ) || ( videoExt === "webm" && ( audioForVideoExt === "m4a" || audioForVideoExt === "mp4" ) ) ) {
ext = "mkv"
ext = "mkv"
} else {
} else {
ext = videoExt ;
ext = videoExt ;
@ -1031,24 +1008,23 @@ function download(
console . log ( "Filename:" , filename ) ;
console . log ( "Filename:" , filename ) ;
/**@type {string} */
/**@type {string} */
let audioFormat ;
let audioFormat = "+ba" ;
if ( audioForVideoFormat _id === "auto" ) {
if ( audioForVideoFormat _id === "auto" ) {
if ( ext === "mp4" ) {
if ( ext === "mp4" ) {
if ( ! ( audioExtensionList . length == 0 ) ) {
if ( ! ( audioExtensionList . length == 0 ) ) {
if ( audioExtensionList . includes ( "m4a" ) ) {
if ( audioExtensionList . includes ( "m4a" ) ) {
audioFormat = "+m4a" ;
audioFormat = "+m4a" ;
} else {
audioFormat = "+ba" ;
}
}
} else {
} else {
audioFormat = "" ;
audioFormat = "" ;
}
}
} else {
audioFormat = "+ba" ;
}
}
} else {
} else if ( audioForVideoFormat _id === "none" ) {
audioFormat = ""
}
else {
audioFormat = ` + ${ audioForVideoFormat _id } ` ;
audioFormat = ` + ${ audioForVideoFormat _id } ` ;
}
}
@ -1159,6 +1135,8 @@ function download(
) ;
) ;
}
}
console . log ( "Spawn args:" + downloadProcess . ytDlpProcess . spawnargs [ downloadProcess . ytDlpProcess . spawnargs . length - 1 ] )
getId ( randomId + ".close" ) . addEventListener ( "click" , ( ) => {
getId ( randomId + ".close" ) . addEventListener ( "click" , ( ) => {
controller . abort ( )
controller . abort ( )
try {
try {