[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.listen(process.env.PORT || 7000, () => {
|
||||
initBestTrackers()
|
||||
.then(() => console.log(`Started addon at: http://localhost:${process.env.PORT || 7000}`))
|
||||
.catch(error => console.error('Failed init trackers', error));
|
||||
.then(() => console.log(`Started addon at: http://localhost:${process.env.PORT || 7000}`));
|
||||
});
|
||||
|
||||
@@ -45,7 +45,7 @@ async function getBestTrackers(retry = 2) {
|
||||
.catch(error => {
|
||||
if (retry === 0) {
|
||||
console.log(`Failed retrieving best trackers: ${error.message}`);
|
||||
return [];
|
||||
throw error;
|
||||
}
|
||||
return getBestTrackers(retry - 1);
|
||||
});
|
||||
|
||||
@@ -15,7 +15,10 @@ const ANIME_PROVIDERS = [
|
||||
function toStreamInfo(record) {
|
||||
const torrentInfo = titleParser.parse(record.torrent.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(
|
||||
[
|
||||
joinDetailParts([record.torrent.title.replace(/[, ]+/g, ' ')]),
|
||||
@@ -33,17 +36,23 @@ function toStreamInfo(record) {
|
||||
const name = joinDetailParts(
|
||||
[
|
||||
joinDetailParts([ADDON_NAME]),
|
||||
joinDetailParts([getQuality(record, torrentInfo, fileInfo)])
|
||||
joinDetailParts([quality])
|
||||
],
|
||||
'',
|
||||
'\n'
|
||||
);
|
||||
const behaviorHints = {
|
||||
bingeGroup: sameInfo
|
||||
? `torrentio|${quality}|${fileInfo.group}`
|
||||
: `torrentio|${record.infoHash}`
|
||||
};
|
||||
|
||||
return {
|
||||
name: name,
|
||||
title: title,
|
||||
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));
|
||||
}
|
||||
|
||||
function enrichStaticInfo(stream) {
|
||||
function enrichStreamSources(stream) {
|
||||
const match = stream.title.match(/⚙.* ([^ \n]+)/);
|
||||
const provider = match && match[1].toLowerCase();
|
||||
if (ANIME_PROVIDERS.includes(provider)) {
|
||||
@@ -107,4 +116,8 @@ function enrichStaticInfo(stream) {
|
||||
return stream;
|
||||
}
|
||||
|
||||
function enrichStaticInfo(stream) {
|
||||
return enrichStreamSources(stream);
|
||||
}
|
||||
|
||||
module.exports = { toStreamInfo, applyStaticInfo };
|
||||
|
||||
@@ -125,7 +125,8 @@ function populateCachedLinks(streams, mochResult) {
|
||||
return {
|
||||
name: `[${mochResult.moch.shortName}+] ${stream.name}`,
|
||||
title: stream.title,
|
||||
url: `${RESOLVER_HOST}/${mochResult.moch.key}/${cachedEntry.url}`
|
||||
url: `${RESOLVER_HOST}/${mochResult.moch.key}/${cachedEntry.url}`,
|
||||
behaviorHints: stream.behaviorHints
|
||||
};
|
||||
}
|
||||
return stream;
|
||||
|
||||
4
addon/package-lock.json
generated
4
addon/package-lock.json
generated
@@ -1779,8 +1779,8 @@
|
||||
}
|
||||
},
|
||||
"parse-torrent-title": {
|
||||
"version": "git://github.com/TheBeastLT/parse-torrent-title.git#ea1c878bbae48e47e97eee1ac4870431bf424244",
|
||||
"from": "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#50f366c14a4aaffbef7a3ad1b31830cf6d1bbac6",
|
||||
"requires": {
|
||||
"moment": "^2.24.0"
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"magnet-uri": "^5.1.7",
|
||||
"named-queue": "^2.2.1",
|
||||
"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-hstore": "^2.3.2",
|
||||
"premiumize-api": "^1.0.3",
|
||||
|
||||
Reference in New Issue
Block a user