mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
ygg_timeout2
This commit is contained in:
@@ -49,7 +49,7 @@ export class DelugeService implements IDownloadClient {
|
|||||||
? new https.Agent({ rejectUnauthorized: false }) : undefined;
|
? new https.Agent({ rejectUnauthorized: false }) : undefined;
|
||||||
if (httpsAgent) logger.info('[Deluge] SSL certificate verification disabled');
|
if (httpsAgent) logger.info('[Deluge] SSL certificate verification disabled');
|
||||||
|
|
||||||
this.client = axios.create({ baseURL: this.baseUrl, timeout: 30000, httpsAgent });
|
this.client = axios.create({ baseURL: this.baseUrl, timeout: 60000, httpsAgent }); // 60 seconds - some indexers (e.g. yggtorrent) enforce a 30s wait before download
|
||||||
}
|
}
|
||||||
|
|
||||||
/** JSON-RPC call with automatic re-authentication on auth failure */
|
/** JSON-RPC call with automatic re-authentication on auth failure */
|
||||||
@@ -190,7 +190,7 @@ export class DelugeService implements IDownloadClient {
|
|||||||
try {
|
try {
|
||||||
torrentResponse = await axios.get(torrentUrl, {
|
torrentResponse = await axios.get(torrentUrl, {
|
||||||
responseType: 'arraybuffer', maxRedirects: 0,
|
responseType: 'arraybuffer', maxRedirects: 0,
|
||||||
validateStatus: (s) => s >= 200 && s < 300, timeout: 30000,
|
validateStatus: (s) => s >= 200 && s < 300, timeout: 60000, // 60 seconds - some indexers (e.g. yggtorrent) enforce a 30s wait before download
|
||||||
});
|
});
|
||||||
if (torrentResponse.data.length > 0) {
|
if (torrentResponse.data.length > 0) {
|
||||||
const magnetMatch = torrentResponse.data.toString().match(/^magnet:\?[^\s]+$/);
|
const magnetMatch = torrentResponse.data.toString().match(/^magnet:\?[^\s]+$/);
|
||||||
@@ -203,7 +203,7 @@ export class DelugeService implements IDownloadClient {
|
|||||||
const loc = error.response.headers['location'];
|
const loc = error.response.headers['location'];
|
||||||
if (loc?.startsWith('magnet:')) return this.addMagnetLink(loc, category, options);
|
if (loc?.startsWith('magnet:')) return this.addMagnetLink(loc, category, options);
|
||||||
if (loc?.startsWith('http://') || loc?.startsWith('https://')) {
|
if (loc?.startsWith('http://') || loc?.startsWith('https://')) {
|
||||||
try { torrentResponse = await axios.get(loc, { responseType: 'arraybuffer', timeout: 30000, maxRedirects: 5 }); }
|
try { torrentResponse = await axios.get(loc, { responseType: 'arraybuffer', timeout: 60000, maxRedirects: 5 }); } // 60 seconds - some indexers (e.g. yggtorrent) enforce a 30s wait before download
|
||||||
catch { throw new Error('Failed to download torrent file after redirect'); }
|
catch { throw new Error('Failed to download torrent file after redirect'); }
|
||||||
} else { throw new Error(`Invalid redirect location: ${loc}`); }
|
} else { throw new Error(`Invalid redirect location: ${loc}`); }
|
||||||
} else { throw new Error(`Failed to download torrent: HTTP ${status}`); }
|
} else { throw new Error(`Failed to download torrent: HTTP ${status}`); }
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ export class QBittorrentService implements IDownloadClient {
|
|||||||
|
|
||||||
this.client = axios.create({
|
this.client = axios.create({
|
||||||
baseURL: `${this.baseUrl}/api/v2`,
|
baseURL: `${this.baseUrl}/api/v2`,
|
||||||
timeout: 30000,
|
timeout: 60000, // 60 seconds - some indexers (e.g. yggtorrent) enforce a 30s wait before download
|
||||||
httpsAgent: this.httpsAgent,
|
httpsAgent: this.httpsAgent,
|
||||||
// Support nginx/Apache reverse proxy with HTTP Basic Auth
|
// Support nginx/Apache reverse proxy with HTTP Basic Auth
|
||||||
auth: {
|
auth: {
|
||||||
@@ -352,7 +352,7 @@ export class QBittorrentService implements IDownloadClient {
|
|||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer',
|
||||||
maxRedirects: 0,
|
maxRedirects: 0,
|
||||||
validateStatus: (status) => status >= 200 && status < 300, // Only 2xx is success
|
validateStatus: (status) => status >= 200 && status < 300, // Only 2xx is success
|
||||||
timeout: 30000, // 30 seconds - public indexers can be slow
|
timeout: 60000, // 60 seconds - some indexers (e.g. yggtorrent) enforce a 30s wait before download
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.info(` Got 2xx response, size=${torrentResponse.data.length} bytes`);
|
logger.info(` Got 2xx response, size=${torrentResponse.data.length} bytes`);
|
||||||
@@ -394,7 +394,7 @@ export class QBittorrentService implements IDownloadClient {
|
|||||||
try {
|
try {
|
||||||
torrentResponse = await axios.get(location, {
|
torrentResponse = await axios.get(location, {
|
||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer',
|
||||||
timeout: 30000,
|
timeout: 60000, // 60 seconds - some indexers (e.g. yggtorrent) enforce a 30s wait before download
|
||||||
maxRedirects: 5,
|
maxRedirects: 5,
|
||||||
});
|
});
|
||||||
logger.info(` After following redirect: size=${torrentResponse.data.length} bytes`);
|
logger.info(` After following redirect: size=${torrentResponse.data.length} bytes`);
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ export class TransmissionService implements IDownloadClient {
|
|||||||
|
|
||||||
this.client = axios.create({
|
this.client = axios.create({
|
||||||
baseURL: this.baseUrl,
|
baseURL: this.baseUrl,
|
||||||
timeout: 30000,
|
timeout: 60000, // 60 seconds - some indexers (e.g. yggtorrent) enforce a 30s wait before download
|
||||||
httpsAgent: this.httpsAgent,
|
httpsAgent: this.httpsAgent,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -274,7 +274,7 @@ export class TransmissionService implements IDownloadClient {
|
|||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer',
|
||||||
maxRedirects: 0,
|
maxRedirects: 0,
|
||||||
validateStatus: (status) => status >= 200 && status < 300,
|
validateStatus: (status) => status >= 200 && status < 300,
|
||||||
timeout: 30000,
|
timeout: 60000, // 60 seconds - some indexers (e.g. yggtorrent) enforce a 30s wait before download
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if response body is a magnet link
|
// Check if response body is a magnet link
|
||||||
@@ -302,7 +302,7 @@ export class TransmissionService implements IDownloadClient {
|
|||||||
try {
|
try {
|
||||||
torrentResponse = await axios.get(location, {
|
torrentResponse = await axios.get(location, {
|
||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer',
|
||||||
timeout: 30000,
|
timeout: 60000, // 60 seconds - some indexers (e.g. yggtorrent) enforce a 30s wait before download
|
||||||
maxRedirects: 5,
|
maxRedirects: 5,
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user