mirror of
https://github.com/TheBeastLT/torrentio-scraper.git
synced 2026-04-21 15:11:56 +00:00
return streams when multiple moch configured but some of them fails, closes #332
This commit is contained in:
parent
a8539c89d8
commit
5bf7fb8230
1 changed files with 13 additions and 13 deletions
|
|
@ -157,19 +157,18 @@ export async function getMochItemMeta(mochKey, itemId, config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function processMochResults(streams, config, results) {
|
function processMochResults(streams, config, results) {
|
||||||
const errorResults = results
|
|
||||||
.map(result => errorStreamResponse(result.moch.key, result.error, config))
|
|
||||||
.filter(errorResponse => errorResponse);
|
|
||||||
if (errorResults.length) {
|
|
||||||
return errorResults;
|
|
||||||
}
|
|
||||||
|
|
||||||
const excludeDownloadLinks = options.excludeDownloadLinks(config);
|
const excludeDownloadLinks = options.excludeDownloadLinks(config);
|
||||||
const mochResults = results.filter(result => result?.mochStreams);
|
const cachedStreams = results.reduce((resultStreams, result) => {
|
||||||
|
if (result?.mochStreams) {
|
||||||
const cachedStreams = mochResults
|
return populateCachedLinks(resultStreams, result, config)
|
||||||
.reduce((resultStreams, mochResult) => populateCachedLinks(resultStreams, mochResult, config), streams);
|
}
|
||||||
const resultStreams = excludeDownloadLinks ? cachedStreams : populateDownloadLinks(cachedStreams, mochResults, config);
|
const errorStream = errorStreamResponse(result.moch.key, result.error, config);
|
||||||
|
if (errorStream) {
|
||||||
|
resultStreams.push(errorStream);
|
||||||
|
}
|
||||||
|
return resultStreams;
|
||||||
|
}, streams);
|
||||||
|
const resultStreams = excludeDownloadLinks ? cachedStreams : populateDownloadLinks(cachedStreams, results, config);
|
||||||
return resultStreams.filter(stream => stream.url);
|
return resultStreams.filter(stream => stream.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -188,7 +187,8 @@ function populateCachedLinks(streams, mochResult, config) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateDownloadLinks(streams, mochResults, config) {
|
function populateDownloadLinks(streams, results, config) {
|
||||||
|
const mochResults = results.filter(result => result.mochStreams);
|
||||||
const torrentStreams = streams.filter(stream => stream.infoHash);
|
const torrentStreams = streams.filter(stream => stream.infoHash);
|
||||||
const seededStreams = streams.filter(stream => !stream.title.includes('👤 0'));
|
const seededStreams = streams.filter(stream => !stream.title.includes('👤 0'));
|
||||||
torrentStreams.forEach(stream => mochResults.forEach(mochResult => {
|
torrentStreams.forEach(stream => mochResults.forEach(mochResult => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue