mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[addon] show filename at the end of moch url for external players
This commit is contained in:
@@ -8,7 +8,7 @@ const putio = require('./putio');
|
|||||||
const StaticResponse = require('./static');
|
const StaticResponse = require('./static');
|
||||||
const { cacheWrapResolvedUrl } = require('../lib/cache');
|
const { cacheWrapResolvedUrl } = require('../lib/cache');
|
||||||
const { timeout } = require('../lib/promises');
|
const { timeout } = require('../lib/promises');
|
||||||
const { BadTokenError } = require('./mochHelper');
|
const { BadTokenError, streamFilename } = require('./mochHelper');
|
||||||
|
|
||||||
const RESOLVE_TIMEOUT = 10 * 60 * 1000; // 10 minutes
|
const RESOLVE_TIMEOUT = 10 * 60 * 1000; // 10 minutes
|
||||||
const MIN_API_KEY_SYMBOLS = 15;
|
const MIN_API_KEY_SYMBOLS = 15;
|
||||||
@@ -151,7 +151,7 @@ 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}/${streamFilename(stream)}`,
|
||||||
behaviorHints: stream.behaviorHints
|
behaviorHints: stream.behaviorHints
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -169,7 +169,7 @@ function populateDownloadLinks(streams, mochResults) {
|
|||||||
streams.push({
|
streams.push({
|
||||||
name: `[${mochResult.moch.shortName} download] ${stream.name}`,
|
name: `[${mochResult.moch.shortName} download] ${stream.name}`,
|
||||||
title: stream.title,
|
title: stream.title,
|
||||||
url: `${RESOLVER_HOST}/${mochResult.moch.key}/${cachedEntry.url}`,
|
url: `${RESOLVER_HOST}/${mochResult.moch.key}/${cachedEntry.url}/${streamFilename(stream)}`,
|
||||||
behaviorHints: stream.behaviorHints
|
behaviorHints: stream.behaviorHints
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,4 +6,13 @@ function chunkArray(arr, size) {
|
|||||||
: [arr];
|
: [arr];
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { chunkArray, BadTokenError }
|
function streamFilename(stream) {
|
||||||
|
const titleParts = stream.title.replace(/\n👤.*/s, '').split('\n');
|
||||||
|
const filePath = titleParts.pop();
|
||||||
|
const filename = titleParts.length
|
||||||
|
? filePath.split('/').pop()
|
||||||
|
: filePath;
|
||||||
|
return encodeURIComponent(filename)
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { chunkArray, BadTokenError, streamFilename }
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ router.get('/:configuration/:resource/:type/:id/:extra?.json', (req, res, next)
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/:moch/:apiKey/:infoHash/:cachedEntryInfo/:fileIndex?', (req, res) => {
|
router.get('/:moch/:apiKey/:infoHash/:cachedEntryInfo/:fileIndex/:filename?', (req, res) => {
|
||||||
const parameters = {
|
const parameters = {
|
||||||
mochKey: req.params.moch,
|
mochKey: req.params.moch,
|
||||||
apiKey: req.params.apiKey,
|
apiKey: req.params.apiKey,
|
||||||
|
|||||||
Reference in New Issue
Block a user