mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
missed a few
This commit is contained in:
@@ -193,6 +193,7 @@ export class DelugeService implements IDownloadClient {
|
|||||||
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: DOWNLOAD_CLIENT_TIMEOUT,
|
validateStatus: (s) => s >= 200 && s < 300, timeout: DOWNLOAD_CLIENT_TIMEOUT,
|
||||||
|
headers: { 'User-Agent': RMAB_USER_AGENT },
|
||||||
});
|
});
|
||||||
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]+$/);
|
||||||
@@ -205,7 +206,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: DOWNLOAD_CLIENT_TIMEOUT, maxRedirects: 5 }); }
|
try { torrentResponse = await axios.get(loc, { responseType: 'arraybuffer', timeout: DOWNLOAD_CLIENT_TIMEOUT, maxRedirects: 5, headers: { 'User-Agent': RMAB_USER_AGENT } }); }
|
||||||
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}`); }
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ export class ProwlarrService {
|
|||||||
extended: 1,
|
extended: 1,
|
||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': 'ReadMeABook',
|
'User-Agent': RMAB_USER_AGENT,
|
||||||
},
|
},
|
||||||
timeout: DOWNLOAD_CLIENT_TIMEOUT,
|
timeout: DOWNLOAD_CLIENT_TIMEOUT,
|
||||||
responseType: 'text', // Get XML as text
|
responseType: 'text', // Get XML as text
|
||||||
|
|||||||
@@ -278,6 +278,7 @@ export class TransmissionService implements IDownloadClient {
|
|||||||
maxRedirects: 0,
|
maxRedirects: 0,
|
||||||
validateStatus: (status) => status >= 200 && status < 300,
|
validateStatus: (status) => status >= 200 && status < 300,
|
||||||
timeout: DOWNLOAD_CLIENT_TIMEOUT,
|
timeout: DOWNLOAD_CLIENT_TIMEOUT,
|
||||||
|
headers: { 'User-Agent': RMAB_USER_AGENT },
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if response body is a magnet link
|
// Check if response body is a magnet link
|
||||||
@@ -307,6 +308,7 @@ export class TransmissionService implements IDownloadClient {
|
|||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer',
|
||||||
timeout: DOWNLOAD_CLIENT_TIMEOUT,
|
timeout: DOWNLOAD_CLIENT_TIMEOUT,
|
||||||
maxRedirects: 5,
|
maxRedirects: 5,
|
||||||
|
headers: { 'User-Agent': RMAB_USER_AGENT },
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
throw new Error('Failed to download torrent file after redirect');
|
throw new Error('Failed to download torrent file after redirect');
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ export interface EbookDownloadResult {
|
|||||||
error?: string;
|
error?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const USER_AGENT = RMAB_USER_AGENT;
|
|
||||||
const REQUEST_DELAY_MS = 1500; // 1.5 second delay between requests
|
const REQUEST_DELAY_MS = 1500; // 1.5 second delay between requests
|
||||||
const DOWNLOAD_TIMEOUT_MS = 60000; // 60 seconds per download attempt
|
const DOWNLOAD_TIMEOUT_MS = 60000; // 60 seconds per download attempt
|
||||||
const MAX_SLOW_LINK_ATTEMPTS = 5;
|
const MAX_SLOW_LINK_ATTEMPTS = 5;
|
||||||
@@ -114,7 +113,7 @@ async function fetchHtml(
|
|||||||
moduleLogger.debug(`Using direct request for: ${url}`);
|
moduleLogger.debug(`Using direct request for: ${url}`);
|
||||||
const response = await retryRequest(() =>
|
const response = await retryRequest(() =>
|
||||||
axios.get(url, {
|
axios.get(url, {
|
||||||
headers: { 'User-Agent': USER_AGENT },
|
headers: { 'User-Agent': RMAB_USER_AGENT },
|
||||||
timeout: 30000,
|
timeout: 30000,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -655,7 +654,7 @@ async function downloadFile(
|
|||||||
const response = await axios.get(url, {
|
const response = await axios.get(url, {
|
||||||
responseType: 'stream',
|
responseType: 'stream',
|
||||||
timeout: DOWNLOAD_TIMEOUT_MS,
|
timeout: DOWNLOAD_TIMEOUT_MS,
|
||||||
headers: { 'User-Agent': USER_AGENT },
|
headers: { 'User-Agent': RMAB_USER_AGENT },
|
||||||
maxRedirects: 5,
|
maxRedirects: 5,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user