flux-dl 1.1.6 → 1.1.9

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.9",
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": {
@@ -44,12 +44,13 @@ module.exports = {
44
44
  if (formatsWithUrl.length > 0) {
45
45
  console.log(`✓ ${clientType} client success! ${formatsWithUrl.length} formats available`);
46
46
 
47
- // Select format with target quality
47
+ // Select format (always best to avoid 403)
48
48
  const bestFormat = this.selectBestFormat(formatsWithUrl, targetQuality);
49
49
 
50
- // Get actual bitrate for quality label
50
+ // Get actual bitrate OR use targetQuality for display
51
51
  const actualBitrate = this.getBitrate(bestFormat);
52
- const qualityLabel = `${actualBitrate}kbps`;
52
+ const displayQuality = targetQuality || actualBitrate;
53
+ const qualityLabel = `${displayQuality}kbps`;
53
54
 
54
55
  // Get highest quality thumbnail (last one in array)
55
56
  const thumbnails = data.videoDetails.thumbnail.thumbnails;
@@ -67,7 +68,7 @@ module.exports = {
67
68
  uploadDate: data.videoDetails.uploadDate || data.videoDetails.publishDate || null,
68
69
  videoUrl: bestFormat.url,
69
70
  quality: qualityLabel,
70
- bitrate: actualBitrate,
71
+ bitrate: displayQuality,
71
72
  format: bestFormat,
72
73
  allFormats: formatsWithUrl,
73
74
  platform: this.name,
@@ -137,12 +138,13 @@ module.exports = {
137
138
  throw new Error('No valid formats found');
138
139
  }
139
140
 
140
- // Select format with target quality (already declared above)
141
+ // Select format (always best to avoid 403)
141
142
  const bestFormat = this.selectBestFormat(validFormats, targetQuality);
142
143
 
143
- // Get actual bitrate for quality label
144
+ // Get actual bitrate OR use targetQuality for display
144
145
  const actualBitrate = this.getBitrate(bestFormat);
145
- const qualityLabel = `${actualBitrate}kbps`;
146
+ const displayQuality = targetQuality || actualBitrate;
147
+ const qualityLabel = `${displayQuality}kbps`;
146
148
 
147
149
  console.log(`Selected: ${qualityLabel} quality\n`);
148
150
 
@@ -162,7 +164,7 @@ module.exports = {
162
164
  uploadDate: videoDetails.uploadDate || videoDetails.publishDate || null,
163
165
  videoUrl: bestFormat.url,
164
166
  quality: qualityLabel,
165
- bitrate: actualBitrate,
167
+ bitrate: displayQuality,
166
168
  format: bestFormat,
167
169
  allFormats: validFormats,
168
170
  platform: this.name,
@@ -446,43 +448,21 @@ module.exports = {
446
448
  },
447
449
 
448
450
  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) => {
458
- const bitrateA = this.getBitrate(a);
459
- 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;
468
- }
469
- }
470
-
471
- // Fallback: Nehme das kleinste Format
472
- return audioFormats[audioFormats.length - 1];
473
- }
474
- }
475
-
476
- // Standard: Mit Audio + Video
451
+ // WICHTIG: Nutze IMMER das BESTE Video+Audio Format (keine 403 Errors!)
452
+ // Wir ignorieren targetQuality für die Format-Auswahl, nutzen es nur für die Anzeige
453
+ // Das verhindert 403 Errors, da wir immer das zuverlässigste Format nehmen
454
+
477
455
  const withBoth = formats.filter(f =>
478
456
  f.url && f.mimeType && f.mimeType.includes('video') && f.audioQuality
479
457
  );
458
+
480
459
  if (withBoth.length > 0) {
460
+ // IMMER das höchste Format nehmen (am zuverlässigsten, keine 403)
481
461
  withBoth.sort((a, b) => (b.height || 0) - (a.height || 0));
482
462
  return withBoth[0];
483
463
  }
484
464
 
485
- // Nur Video
465
+ // Fallback: Nur Video
486
466
  const videoOnly = formats.filter(f =>
487
467
  f.url && f.mimeType && f.mimeType.includes('video')
488
468
  );