frostpv 1.0.17 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +8 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1236,22 +1236,23 @@ async function downloadYoutubeVideo(url, config, cookies, YTBmaxduration, isAudi
|
|
|
1236
1236
|
throw new Error('❌ No suitable audio format found.');
|
|
1237
1237
|
}
|
|
1238
1238
|
} else {
|
|
1239
|
+
// Filter for formats that have both audio and video (muxed)
|
|
1240
|
+
// We prioritize higher quality but limit to 1080p if possible
|
|
1239
1241
|
let formats = info.formats.filter(format => {
|
|
1240
|
-
return format.
|
|
1241
|
-
format.hasAudio && format.hasVideo;
|
|
1242
|
+
return format.hasAudio && format.hasVideo && (!format.height || format.height <= 1080);
|
|
1242
1243
|
});
|
|
1243
1244
|
|
|
1244
1245
|
if (formats.length === 0) {
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
});
|
|
1246
|
+
// If no 1080p muxed formats, take any muxed format
|
|
1247
|
+
formats = info.formats.filter(format => format.hasAudio && format.hasVideo);
|
|
1248
1248
|
}
|
|
1249
1249
|
|
|
1250
1250
|
if (formats.length === 0) {
|
|
1251
|
-
throw new Error('❌ No suitable video format found.');
|
|
1251
|
+
throw new Error('❌ No suitable video format found with both audio and video.');
|
|
1252
1252
|
}
|
|
1253
1253
|
|
|
1254
|
-
|
|
1254
|
+
// Sort by resolution (height) descending to get best quality
|
|
1255
|
+
bestFormat = formats.sort((a, b) => (b.height || 0) - (a.height || 0))[0];
|
|
1255
1256
|
}
|
|
1256
1257
|
|
|
1257
1258
|
const ext = isAudioOnly ? 'mp3' : 'mp4';
|