mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[addon] updates to use https proxy agent
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
const AllDebridClient = require('all-debrid-api');
|
||||
const { isVideo, isArchive } = require('../lib/extension');
|
||||
const StaticResponse = require('./static');
|
||||
const { getRandomProxy, getRandomUserAgent } = require('../lib/request_helper');
|
||||
const { getRandomProxy, getProxyAgent, getRandomUserAgent } = require('../lib/requestHelper');
|
||||
const { cacheWrapProxy, cacheUserAgent } = require('../lib/cache');
|
||||
|
||||
async function getCachedStreams(streams, apiKey) {
|
||||
@@ -101,8 +101,9 @@ async function _unrestrictLink(AD, torrent, encodedFileName, fileIndex) {
|
||||
async function getDefaultOptions(id, ip) {
|
||||
const userAgent = await cacheUserAgent(id, () => getRandomUserAgent()).catch(() => getRandomUserAgent());
|
||||
const proxy = await cacheWrapProxy('moch', () => getRandomProxy()).catch(() => getRandomProxy());
|
||||
const agent = getProxyAgent(proxy);
|
||||
|
||||
return { proxy: proxy, headers: { 'User-Agent': userAgent } };
|
||||
return { timeout: 30000, agent: agent, headers: { 'User-Agent': userAgent } };
|
||||
}
|
||||
|
||||
function statusError(statusCode) {
|
||||
|
||||
@@ -2,7 +2,7 @@ const PremiumizeClient = require('premiumize-api');
|
||||
const { encode } = require('magnet-uri');
|
||||
const { isVideo } = require('../lib/extension');
|
||||
const StaticResponse = require('./static');
|
||||
const { getRandomProxy, getRandomUserAgent } = require('../lib/request_helper');
|
||||
const { getRandomProxy, getProxyAgent, getRandomUserAgent } = require('../lib/requestHelper');
|
||||
const { cacheWrapProxy, cacheUserAgent } = require('../lib/cache');
|
||||
|
||||
async function getCachedStreams(streams, apiKey) {
|
||||
@@ -107,8 +107,9 @@ function statusReady(status) {
|
||||
async function getDefaultOptions(id, ip) {
|
||||
const userAgent = await cacheUserAgent(id, () => getRandomUserAgent()).catch(() => getRandomUserAgent());
|
||||
const proxy = await cacheWrapProxy('moch', () => getRandomProxy()).catch(() => getRandomProxy());
|
||||
const agent = getProxyAgent(proxy);
|
||||
|
||||
return { proxy: proxy, headers: { 'User-Agent': userAgent } };
|
||||
return { timeout: 30000, agent: agent, headers: { 'User-Agent': userAgent } };
|
||||
}
|
||||
|
||||
module.exports = { getCachedStreams, resolve };
|
||||
@@ -3,7 +3,7 @@ const { encode } = require('magnet-uri');
|
||||
const { isVideo, isArchive } = require('../lib/extension');
|
||||
const delay = require('./delay');
|
||||
const StaticResponse = require('./static');
|
||||
const { getRandomProxy, getRandomUserAgent, blacklistProxy } = require('../lib/request_helper');
|
||||
const { getRandomProxy, getProxyAgent, getRandomUserAgent, blacklistProxy } = require('../lib/requestHelper');
|
||||
const { cacheWrapProxy, cacheUserAgent, uncacheProxy } = require('../lib/cache');
|
||||
|
||||
const MIN_SIZE = 15728640; // 15 MB
|
||||
@@ -204,8 +204,9 @@ function statusReady(status) {
|
||||
async function getDefaultOptions(id) {
|
||||
const userAgent = await cacheUserAgent(id, () => getRandomUserAgent()).catch(() => getRandomUserAgent());
|
||||
const proxy = await cacheWrapProxy('moch', () => getRandomProxy()).catch(() => getRandomProxy());
|
||||
const agent = getProxyAgent(proxy);
|
||||
|
||||
return { timeout: 30000, proxy: proxy, headers: { 'User-Agent': userAgent } };
|
||||
return { timeout: 30000, agent: agent, headers: { 'User-Agent': userAgent } };
|
||||
}
|
||||
|
||||
module.exports = { getCachedStreams, resolve };
|
||||
Reference in New Issue
Block a user