flux-dl 1.1.6 → 1.1.7
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/package.json +1 -1
- package/src/platforms/youtube.js +33 -28
package/package.json
CHANGED
package/src/platforms/youtube.js
CHANGED
|
@@ -446,43 +446,48 @@ module.exports = {
|
|
|
446
446
|
},
|
|
447
447
|
|
|
448
448
|
selectBestFormat(formats, targetQuality = null) {
|
|
449
|
-
//
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
)
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
449
|
+
// WICHTIG: Nutze IMMER Video+Audio Formate (keine 403 Errors!)
|
|
450
|
+
// Audio-only Formate geben oft 403 Forbidden
|
|
451
|
+
|
|
452
|
+
const withBoth = formats.filter(f =>
|
|
453
|
+
f.url && f.mimeType && f.mimeType.includes('video') && f.audioQuality
|
|
454
|
+
);
|
|
455
|
+
|
|
456
|
+
if (withBoth.length > 0) {
|
|
457
|
+
// Wenn targetQuality angegeben, wähle Format mit passender Audio-Bitrate
|
|
458
|
+
if (targetQuality) {
|
|
459
|
+
// Sortiere nach Audio-Bitrate-Nähe zur Ziel-Qualität
|
|
460
|
+
withBoth.sort((a, b) => {
|
|
458
461
|
const bitrateA = this.getBitrate(a);
|
|
459
462
|
const bitrateB = this.getBitrate(b);
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
if (
|
|
467
|
-
return
|
|
463
|
+
|
|
464
|
+
// Bevorzuge Formate unter oder gleich der Ziel-Qualität
|
|
465
|
+
const diffA = Math.abs(bitrateA - targetQuality);
|
|
466
|
+
const diffB = Math.abs(bitrateB - targetQuality);
|
|
467
|
+
|
|
468
|
+
// Wenn beide über Ziel, nehme kleineres
|
|
469
|
+
if (bitrateA > targetQuality && bitrateB > targetQuality) {
|
|
470
|
+
return bitrateA - bitrateB;
|
|
468
471
|
}
|
|
469
|
-
|
|
472
|
+
|
|
473
|
+
// Wenn beide unter Ziel, nehme größeres
|
|
474
|
+
if (bitrateA <= targetQuality && bitrateB <= targetQuality) {
|
|
475
|
+
return bitrateB - bitrateA;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// Sonst nehme das nähere
|
|
479
|
+
return diffA - diffB;
|
|
480
|
+
});
|
|
470
481
|
|
|
471
|
-
|
|
472
|
-
return audioFormats[audioFormats.length - 1];
|
|
482
|
+
return withBoth[0];
|
|
473
483
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
// Standard: Mit Audio + Video
|
|
477
|
-
const withBoth = formats.filter(f =>
|
|
478
|
-
f.url && f.mimeType && f.mimeType.includes('video') && f.audioQuality
|
|
479
|
-
);
|
|
480
|
-
if (withBoth.length > 0) {
|
|
484
|
+
|
|
485
|
+
// Ohne targetQuality: Nehme höchste Video-Qualität
|
|
481
486
|
withBoth.sort((a, b) => (b.height || 0) - (a.height || 0));
|
|
482
487
|
return withBoth[0];
|
|
483
488
|
}
|
|
484
489
|
|
|
485
|
-
// Nur Video
|
|
490
|
+
// Fallback: Nur Video (sollte nicht passieren)
|
|
486
491
|
const videoOnly = formats.filter(f =>
|
|
487
492
|
f.url && f.mimeType && f.mimeType.includes('video')
|
|
488
493
|
);
|