flux-dl 1.1.7 → 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 +1 -1
- package/src/platforms/youtube.js +15 -40
package/package.json
CHANGED
package/src/platforms/youtube.js
CHANGED
|
@@ -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
|
|
47
|
+
// Select format (always best to avoid 403)
|
|
48
48
|
const bestFormat = this.selectBestFormat(formatsWithUrl, targetQuality);
|
|
49
49
|
|
|
50
|
-
// Get actual bitrate for
|
|
50
|
+
// Get actual bitrate OR use targetQuality for display
|
|
51
51
|
const actualBitrate = this.getBitrate(bestFormat);
|
|
52
|
-
const
|
|
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:
|
|
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
|
|
141
|
+
// Select format (always best to avoid 403)
|
|
141
142
|
const bestFormat = this.selectBestFormat(validFormats, targetQuality);
|
|
142
143
|
|
|
143
|
-
// Get actual bitrate for
|
|
144
|
+
// Get actual bitrate OR use targetQuality for display
|
|
144
145
|
const actualBitrate = this.getBitrate(bestFormat);
|
|
145
|
-
const
|
|
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:
|
|
167
|
+
bitrate: displayQuality,
|
|
166
168
|
format: bestFormat,
|
|
167
169
|
allFormats: validFormats,
|
|
168
170
|
platform: this.name,
|
|
@@ -446,48 +448,21 @@ module.exports = {
|
|
|
446
448
|
},
|
|
447
449
|
|
|
448
450
|
selectBestFormat(formats, targetQuality = null) {
|
|
449
|
-
// WICHTIG: Nutze IMMER Video+Audio
|
|
450
|
-
//
|
|
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
|
|
451
454
|
|
|
452
455
|
const withBoth = formats.filter(f =>
|
|
453
456
|
f.url && f.mimeType && f.mimeType.includes('video') && f.audioQuality
|
|
454
457
|
);
|
|
455
458
|
|
|
456
459
|
if (withBoth.length > 0) {
|
|
457
|
-
//
|
|
458
|
-
if (targetQuality) {
|
|
459
|
-
// Sortiere nach Audio-Bitrate-Nähe zur Ziel-Qualität
|
|
460
|
-
withBoth.sort((a, b) => {
|
|
461
|
-
const bitrateA = this.getBitrate(a);
|
|
462
|
-
const bitrateB = this.getBitrate(b);
|
|
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;
|
|
471
|
-
}
|
|
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
|
-
});
|
|
481
|
-
|
|
482
|
-
return withBoth[0];
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
// Ohne targetQuality: Nehme höchste Video-Qualität
|
|
460
|
+
// IMMER das höchste Format nehmen (am zuverlässigsten, keine 403)
|
|
486
461
|
withBoth.sort((a, b) => (b.height || 0) - (a.height || 0));
|
|
487
462
|
return withBoth[0];
|
|
488
463
|
}
|
|
489
464
|
|
|
490
|
-
// Fallback: Nur Video
|
|
465
|
+
// Fallback: Nur Video
|
|
491
466
|
const videoOnly = formats.filter(f =>
|
|
492
467
|
f.url && f.mimeType && f.mimeType.includes('video')
|
|
493
468
|
);
|