flux-dl 1.0.1 → 1.0.3

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.0.1",
3
+ "version": "1.0.3",
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": {
@@ -94,14 +94,28 @@ class VideoDownloader {
94
94
  const referer = `https://www.youtube.com/watch?v=${info.videoId}`;
95
95
  const writer = fs.createWriteStream(filepath);
96
96
 
97
+ let bytesReceived = 0;
97
98
  const stream = await this.spoofing.downloadStream(audioFormat.url, referer, (percent) => {
98
99
  process.stdout.write(`\rProgress: ${percent}%`);
99
100
  });
100
101
 
102
+ // Track bytes to detect 403 with empty response
103
+ stream.on('data', (chunk) => {
104
+ bytesReceived += chunk.length;
105
+ });
106
+
101
107
  stream.pipe(writer);
102
108
 
103
109
  await new Promise((resolve, reject) => {
104
- writer.on('finish', resolve);
110
+ writer.on('finish', () => {
111
+ // Check if we actually received data
112
+ if (bytesReceived === 0) {
113
+ fs.unlinkSync(filepath); // Delete empty file
114
+ reject(new Error('403 Forbidden: No data received (empty stream)'));
115
+ } else {
116
+ resolve();
117
+ }
118
+ });
105
119
  writer.on('error', reject);
106
120
  });
107
121
 
@@ -211,7 +211,7 @@ class BrowserEmulation {
211
211
  maxRedirects: 10,
212
212
  timeout: 0,
213
213
  decompress: false, // WICHTIG: Keine automatische Dekompression
214
- validateStatus: (status) => status >= 200 && status < 400
214
+ validateStatus: (status) => status >= 200 && status < 500 // Accept 403 too
215
215
  };
216
216
 
217
217
  const response = await axios(config);
@@ -103,9 +103,9 @@ class RequestSpoofing {
103
103
  rejectUnauthorized: false
104
104
  }),
105
105
  maxRedirects: 10,
106
- timeout: 0, // Kein Timeout für große Downloads
107
- decompress: false, // WICHTIG: Keine automatische Dekompression
108
- validateStatus: (status) => status >= 200 && status < 400
106
+ timeout: 0,
107
+ decompress: false,
108
+ validateStatus: (status) => status >= 200 && status < 500 // Accept 403 too
109
109
  };
110
110
 
111
111
  try {
@@ -130,12 +130,9 @@ class RequestSpoofing {
130
130
 
131
131
  return response.data;
132
132
  } catch (error) {
133
- if (error.response && error.response.status === 403) {
134
- console.warn('Warning: 403 Forbidden, but continuing...');
135
- // Don't throw - sometimes it still works
136
- } else {
137
- throw error;
138
- }
133
+ // Log but don't throw - let it fail gracefully
134
+ console.warn('Download stream error:', error.message);
135
+ throw error;
139
136
  }
140
137
  }
141
138
  }