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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flux-dl",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "Leistungsstarke Video-Downloader Library für YouTube, Vimeo und Dailymotion - komplett in JavaScript, keine externen Binaries",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -446,43 +446,48 @@ module.exports = {
446
446
  },
447
447
 
448
448
  selectBestFormat(formats, targetQuality = null) {
449
- // Wenn targetQuality angegeben, nutze Audio-only Format mit passender Bitrate
450
- if (targetQuality) {
451
- const audioFormats = formats.filter(f =>
452
- f.url && f.mimeType && f.mimeType.includes('audio')
453
- );
454
-
455
- if (audioFormats.length > 0) {
456
- // Sortiere nach Bitrate-Nähe zur Ziel-Qualität
457
- audioFormats.sort((a, b) => {
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
- return Math.abs(bitrateA - targetQuality) - Math.abs(bitrateB - targetQuality);
461
- });
462
-
463
- // Finde Format das unter oder gleich der Ziel-Qualität ist
464
- for (const format of audioFormats) {
465
- const bitrate = this.getBitrate(format);
466
- if (bitrate <= targetQuality) {
467
- return format;
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
- // Fallback: Nehme das kleinste Format
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
  );