mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[addon] add bingeGroup to stream responses
This commit is contained in:
@@ -8,6 +8,5 @@ app.use(express.static('static', { maxAge: '1y' }));
|
|||||||
app.use((req, res, next) => serverless(req, res, next));
|
app.use((req, res, next) => serverless(req, res, next));
|
||||||
app.listen(process.env.PORT || 7000, () => {
|
app.listen(process.env.PORT || 7000, () => {
|
||||||
initBestTrackers()
|
initBestTrackers()
|
||||||
.then(() => console.log(`Started addon at: http://localhost:${process.env.PORT || 7000}`))
|
.then(() => console.log(`Started addon at: http://localhost:${process.env.PORT || 7000}`));
|
||||||
.catch(error => console.error('Failed init trackers', error));
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ async function getBestTrackers(retry = 2) {
|
|||||||
.catch(error => {
|
.catch(error => {
|
||||||
if (retry === 0) {
|
if (retry === 0) {
|
||||||
console.log(`Failed retrieving best trackers: ${error.message}`);
|
console.log(`Failed retrieving best trackers: ${error.message}`);
|
||||||
return [];
|
throw error;
|
||||||
}
|
}
|
||||||
return getBestTrackers(retry - 1);
|
return getBestTrackers(retry - 1);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ const ANIME_PROVIDERS = [
|
|||||||
function toStreamInfo(record) {
|
function toStreamInfo(record) {
|
||||||
const torrentInfo = titleParser.parse(record.torrent.title);
|
const torrentInfo = titleParser.parse(record.torrent.title);
|
||||||
const fileInfo = titleParser.parse(record.title);
|
const fileInfo = titleParser.parse(record.title);
|
||||||
const sameInfo = !Number.isInteger(record.fileIndex) || Math.abs(record.size / record.torrent.size - 1) < SIZE_DELTA;
|
const sameInfo = !Number.isInteger(record.fileIndex)
|
||||||
|
|| Math.abs(record.size / record.torrent.size - 1) < SIZE_DELTA
|
||||||
|
|| record.title.includes(record.torrent.title);
|
||||||
|
const quality = getQuality(record, torrentInfo, fileInfo);
|
||||||
const title = joinDetailParts(
|
const title = joinDetailParts(
|
||||||
[
|
[
|
||||||
joinDetailParts([record.torrent.title.replace(/[, ]+/g, ' ')]),
|
joinDetailParts([record.torrent.title.replace(/[, ]+/g, ' ')]),
|
||||||
@@ -33,17 +36,23 @@ function toStreamInfo(record) {
|
|||||||
const name = joinDetailParts(
|
const name = joinDetailParts(
|
||||||
[
|
[
|
||||||
joinDetailParts([ADDON_NAME]),
|
joinDetailParts([ADDON_NAME]),
|
||||||
joinDetailParts([getQuality(record, torrentInfo, fileInfo)])
|
joinDetailParts([quality])
|
||||||
],
|
],
|
||||||
'',
|
'',
|
||||||
'\n'
|
'\n'
|
||||||
);
|
);
|
||||||
|
const behaviorHints = {
|
||||||
|
bingeGroup: sameInfo
|
||||||
|
? `torrentio|${quality}|${fileInfo.group}`
|
||||||
|
: `torrentio|${record.infoHash}`
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: name,
|
name: name,
|
||||||
title: title,
|
title: title,
|
||||||
infoHash: record.infoHash,
|
infoHash: record.infoHash,
|
||||||
fileIdx: record.fileIndex
|
fileIdx: record.fileIndex,
|
||||||
|
behaviorHints: record.torrent.type !== Type.MOVIE ? behaviorHints : null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +105,7 @@ function applyStaticInfo(streams) {
|
|||||||
return streams.map(stream => enrichStaticInfo(stream));
|
return streams.map(stream => enrichStaticInfo(stream));
|
||||||
}
|
}
|
||||||
|
|
||||||
function enrichStaticInfo(stream) {
|
function enrichStreamSources(stream) {
|
||||||
const match = stream.title.match(/⚙.* ([^ \n]+)/);
|
const match = stream.title.match(/⚙.* ([^ \n]+)/);
|
||||||
const provider = match && match[1].toLowerCase();
|
const provider = match && match[1].toLowerCase();
|
||||||
if (ANIME_PROVIDERS.includes(provider)) {
|
if (ANIME_PROVIDERS.includes(provider)) {
|
||||||
@@ -107,4 +116,8 @@ function enrichStaticInfo(stream) {
|
|||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function enrichStaticInfo(stream) {
|
||||||
|
return enrichStreamSources(stream);
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = { toStreamInfo, applyStaticInfo };
|
module.exports = { toStreamInfo, applyStaticInfo };
|
||||||
|
|||||||
@@ -125,7 +125,8 @@ function populateCachedLinks(streams, mochResult) {
|
|||||||
return {
|
return {
|
||||||
name: `[${mochResult.moch.shortName}+] ${stream.name}`,
|
name: `[${mochResult.moch.shortName}+] ${stream.name}`,
|
||||||
title: stream.title,
|
title: stream.title,
|
||||||
url: `${RESOLVER_HOST}/${mochResult.moch.key}/${cachedEntry.url}`
|
url: `${RESOLVER_HOST}/${mochResult.moch.key}/${cachedEntry.url}`,
|
||||||
|
behaviorHints: stream.behaviorHints
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return stream;
|
return stream;
|
||||||
|
|||||||
4
addon/package-lock.json
generated
4
addon/package-lock.json
generated
@@ -1779,8 +1779,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"parse-torrent-title": {
|
"parse-torrent-title": {
|
||||||
"version": "git://github.com/TheBeastLT/parse-torrent-title.git#ea1c878bbae48e47e97eee1ac4870431bf424244",
|
"version": "git://github.com/TheBeastLT/parse-torrent-title.git#50f366c14a4aaffbef7a3ad1b31830cf6d1bbac6",
|
||||||
"from": "git://github.com/TheBeastLT/parse-torrent-title.git#ea1c878bbae48e47e97eee1ac4870431bf424244",
|
"from": "git://github.com/TheBeastLT/parse-torrent-title.git#50f366c14a4aaffbef7a3ad1b31830cf6d1bbac6",
|
||||||
"requires": {
|
"requires": {
|
||||||
"moment": "^2.24.0"
|
"moment": "^2.24.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
"magnet-uri": "^5.1.7",
|
"magnet-uri": "^5.1.7",
|
||||||
"named-queue": "^2.2.1",
|
"named-queue": "^2.2.1",
|
||||||
"needle": "^2.2.4",
|
"needle": "^2.2.4",
|
||||||
"parse-torrent-title": "git://github.com/TheBeastLT/parse-torrent-title.git#ea1c878bbae48e47e97eee1ac4870431bf424244",
|
"parse-torrent-title": "git://github.com/TheBeastLT/parse-torrent-title.git#50f366c14a4aaffbef7a3ad1b31830cf6d1bbac6",
|
||||||
"pg": "^7.8.2",
|
"pg": "^7.8.2",
|
||||||
"pg-hstore": "^2.3.2",
|
"pg-hstore": "^2.3.2",
|
||||||
"premiumize-api": "^1.0.3",
|
"premiumize-api": "^1.0.3",
|
||||||
|
|||||||
Reference in New Issue
Block a user