mirror of
https://github.com/TheBeastLT/torrentio-scraper.git
synced 2026-04-21 15:11:56 +00:00
tb logging improvement
This commit is contained in:
parent
ffe1a3382d
commit
7b5c87796e
1 changed files with 3 additions and 4 deletions
|
|
@ -9,7 +9,7 @@ const KEY = 'torbox';
|
||||||
const timeout = 30000;
|
const timeout = 30000;
|
||||||
const baseUrl = 'https://api.torbox.app/v1'
|
const baseUrl = 'https://api.torbox.app/v1'
|
||||||
|
|
||||||
export async function getCachedStreams(streams, apiKey, ip) {
|
export async function getCachedStreams(streams, apiKey) {
|
||||||
const hashBatches = chunkArray(streams.map(stream => stream.infoHash), 150)
|
const hashBatches = chunkArray(streams.map(stream => stream.infoHash), 150)
|
||||||
.map(hashes => getAvailabilityResponse(apiKey, hashes));
|
.map(hashes => getAvailabilityResponse(apiKey, hashes));
|
||||||
const available = await Promise.all(hashBatches)
|
const available = await Promise.all(hashBatches)
|
||||||
|
|
@ -17,11 +17,10 @@ export async function getCachedStreams(streams, apiKey, ip) {
|
||||||
.map(data => data.map(entry => entry.hash))
|
.map(data => data.map(entry => entry.hash))
|
||||||
.reduce((all, result) => all.concat(result), []))
|
.reduce((all, result) => all.concat(result), []))
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
console.log('Failed TorBox cached torrent availability request: ', JSON.stringify(error.message || error));
|
||||||
if (toCommonError(error)) {
|
if (toCommonError(error)) {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
const message = error.message || error;
|
|
||||||
console.log('Failed TorBox cached torrent availability request: ', JSON.stringify(message));
|
|
||||||
return undefined;
|
return undefined;
|
||||||
});
|
});
|
||||||
return available && streams
|
return available && streams
|
||||||
|
|
@ -263,7 +262,7 @@ function getHeaders(apiKey) {
|
||||||
|
|
||||||
export function toCommonError(data) {
|
export function toCommonError(data) {
|
||||||
const error = data?.response?.data || data;
|
const error = data?.response?.data || data;
|
||||||
if (['AUTH_ERROR', 'BAD_TOKEN'].includes(error?.error)) {
|
if (['BAD_TOKEN'].includes(error?.error)) {
|
||||||
return BadTokenError;
|
return BadTokenError;
|
||||||
}
|
}
|
||||||
if (isAccessDeniedError(error)) {
|
if (isAccessDeniedError(error)) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue