diff --git a/src/extractor/ExtractorRegistry.ts b/src/extractor/ExtractorRegistry.ts index 96a45ad..b65bc83 100644 --- a/src/extractor/ExtractorRegistry.ts +++ b/src/extractor/ExtractorRegistry.ts @@ -3,7 +3,7 @@ import KeyvSqlite from '@keyv/sqlite'; import { Cacheable, CacheableMemory, Keyv } from 'cacheable'; import winston from 'winston'; import { Context, Meta, UrlResult } from '../types'; -import { getCacheDir, isExtractorDisabled, noCache } from '../utils'; +import { getCacheDir, isExtractorDisabled } from '../utils'; import { Extractor } from './Extractor'; export class ExtractorRegistry { @@ -41,7 +41,7 @@ export class ExtractorRegistry { const storedDataRaw = await this.urlResultCache.getRaw(cacheKey); const expires = storedDataRaw?.expires; - if (storedDataRaw && expires && !noCache(ctx.config)) { + if (storedDataRaw && expires) { // Ignore the cache randomly after at least 2/3 of the TTL passed to start refreshing results slowly const refreshTimestamp = this.randomInteger(expires - extractor.ttl * (2 / 3), expires); const now = Date.now(); diff --git a/src/source/Source.ts b/src/source/Source.ts index 2ef1bd6..3f5feec 100644 --- a/src/source/Source.ts +++ b/src/source/Source.ts @@ -4,7 +4,7 @@ import { Cacheable, CacheableMemory, Keyv } from 'cacheable'; import { ContentType } from 'stremio-addon-sdk'; import { NotFoundError } from '../error'; import { Context, CountryCode, Meta } from '../types'; -import { getCacheDir, Id, noCache } from '../utils'; +import { getCacheDir, Id } from '../utils'; export interface SourceResult { url: URL; @@ -44,7 +44,7 @@ export abstract class Source { let sourceResults = (await Source.sourceResultCache.get(cacheKey)) ?.map(sourceResult => ({ ...sourceResult, url: new URL(sourceResult.url) })); - if (!sourceResults || noCache(ctx.config)) { + if (!sourceResults) { try { sourceResults = await this.handleInternal(ctx, type, id); } catch (error) { diff --git a/src/types.ts b/src/types.ts index c04729e..0857a68 100644 --- a/src/types.ts +++ b/src/types.ts @@ -17,7 +17,7 @@ export type CustomManifest = Manifest & { }; }; -export type Config = Partial & Record<`disableExtractor_${string}`, string>>; +export type Config = Partial & Record<`disableExtractor_${string}`, string>>; export enum CountryCode { multi = 'multi', diff --git a/src/utils/Fetcher.ts b/src/utils/Fetcher.ts index eb5e9c0..9731d44 100644 --- a/src/utils/Fetcher.ts +++ b/src/utils/Fetcher.ts @@ -7,7 +7,6 @@ import { fetch, Headers, RequestInit, Response } from 'undici'; import winston from 'winston'; import { BlockedError, HttpError, NotFoundError, QueueIsFullError, TimeoutError, TooManyRequestsError, TooManyTimeoutsError } from '../error'; import { BlockedReason, Context } from '../types'; -import { noCache } from './config'; import { createDispatcher } from './dispatcher'; import { envGet } from './env'; @@ -234,8 +233,8 @@ export class Fetcher { const cacheKey = this.determineCacheKey(url, init); let httpCacheItem = await this.cacheGet(cacheKey); - const disableCache = init?.noCache ?? noCache(ctx.config); - if (httpCacheItem && !disableCache) { + const noCache = init?.noCache ?? false; + if (httpCacheItem && !noCache) { this.logger.info(`Cached fetch ${request.method} ${url}: ${httpCacheItem.status} (${httpCacheItem.statusText})`, ctx); return this.handleHttpCacheItem(ctx, httpCacheItem, url, init); } diff --git a/src/utils/__snapshots__/manifest.test.ts.snap b/src/utils/__snapshots__/manifest.test.ts.snap index e1a58a7..452b4fb 100644 --- a/src/utils/__snapshots__/manifest.test.ts.snap +++ b/src/utils/__snapshots__/manifest.test.ts.snap @@ -72,11 +72,6 @@ exports[`buildManifest default manifest 1`] = ` "title": "Proxy Config", "type": "text", }, - { - "key": "noCache", - "title": "Disable cache", - "type": "checkbox", - }, ], "description": "Provides HTTP URLs from streaming websites. Configure add-on for additional languages. Add MediaFlow proxy for more URLs. @@ -136,11 +131,6 @@ exports[`buildManifest disable extractors 1`] = ` "title": "Proxy Config", "type": "text", }, - { - "key": "noCache", - "title": "Disable cache", - "type": "checkbox", - }, { "default": "checked", "key": "disableExtractor_doodstream", @@ -155,9 +145,10 @@ exports[`buildManifest disable extractors 1`] = ` ] `; -exports[`buildManifest has checked includeExternalUrls 1`] = ` +exports[`buildManifest has checked showErrors and includeExternalUrls 1`] = ` [ { + "default": "checked", "key": "showErrors", "title": "Show errors", "type": "checkbox", @@ -186,89 +177,6 @@ exports[`buildManifest has checked includeExternalUrls 1`] = ` "title": "Proxy Config", "type": "text", }, - { - "key": "noCache", - "title": "Disable cache", - "type": "checkbox", - }, -] -`; - -exports[`buildManifest has checked noCache 1`] = ` -[ - { - "key": "showErrors", - "title": "Show errors", - "type": "checkbox", - }, - { - "key": "includeExternalUrls", - "title": "Include external URLs in results", - "type": "checkbox", - }, - { - "default": "", - "key": "mediaFlowProxyUrl", - "title": "MediaFlow Proxy URL", - "type": "text", - }, - { - "default": "", - "key": "mediaFlowProxyPassword", - "title": "MediaFlow Proxy Password", - "type": "password", - }, - { - "default": "", - "key": "proxyConfig", - "title": "Proxy Config", - "type": "text", - }, - { - "default": "checked", - "key": "noCache", - "title": "Disable cache", - "type": "checkbox", - }, -] -`; - -exports[`buildManifest has checked showErrors 1`] = ` -[ - { - "default": "checked", - "key": "showErrors", - "title": "Show errors", - "type": "checkbox", - }, - { - "key": "includeExternalUrls", - "title": "Include external URLs in results", - "type": "checkbox", - }, - { - "default": "", - "key": "mediaFlowProxyUrl", - "title": "MediaFlow Proxy URL", - "type": "text", - }, - { - "default": "", - "key": "mediaFlowProxyPassword", - "title": "MediaFlow Proxy Password", - "type": "password", - }, - { - "default": "", - "key": "proxyConfig", - "title": "Proxy Config", - "type": "text", - }, - { - "key": "noCache", - "title": "Disable cache", - "type": "checkbox", - }, ] `; @@ -319,11 +227,6 @@ exports[`buildManifest has checked source with appropriate config 1`] = ` "title": "Proxy Config", "type": "text", }, - { - "key": "noCache", - "title": "Disable cache", - "type": "checkbox", - }, ] `; @@ -382,11 +285,6 @@ exports[`buildManifest has unchecked source without a config 1`] = ` "title": "Proxy Config", "type": "text", }, - { - "key": "noCache", - "title": "Disable cache", - "type": "checkbox", - }, ] `; @@ -420,10 +318,5 @@ exports[`buildManifest showErrors and includeExternalUrls are unchecked by defau "title": "Proxy Config", "type": "text", }, - { - "key": "noCache", - "title": "Disable cache", - "type": "checkbox", - }, ] `; diff --git a/src/utils/config.ts b/src/utils/config.ts index 2702554..fd503db 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -9,8 +9,6 @@ export const showErrors = (config: Config): boolean => 'showErrors' in config; export const showExternalUrls = (config: Config): boolean => 'includeExternalUrls' in config; -export const noCache = (config: Config): boolean => 'noCache' in config; - export const hasMultiEnabled = (config: Config): boolean => 'multi' in config; export const disableExtractorConfigKey = (extractor: Extractor): string => `disableExtractor_${extractor.id}`; diff --git a/src/utils/manifest.test.ts b/src/utils/manifest.test.ts index 9e71309..bbe709d 100644 --- a/src/utils/manifest.test.ts +++ b/src/utils/manifest.test.ts @@ -50,20 +50,8 @@ describe('buildManifest', () => { expect(manifest.config).toMatchSnapshot(); }); - test('has checked showErrors', () => { - const manifest = buildManifest([], [], { showErrors: 'on' }); - - expect(manifest.config).toMatchSnapshot(); - }); - - test('has checked includeExternalUrls', () => { - const manifest = buildManifest([], [], { includeExternalUrls: 'on' }); - - expect(manifest.config).toMatchSnapshot(); - }); - - test('has checked noCache', () => { - const manifest = buildManifest([], [], { noCache: 'on' }); + test('has checked showErrors and includeExternalUrls', () => { + const manifest = buildManifest([], [], { showErrors: 'on', includeExternalUrls: 'on' }); expect(manifest.config).toMatchSnapshot(); }); diff --git a/src/utils/manifest.ts b/src/utils/manifest.ts index a1c8d48..e954fc5 100644 --- a/src/utils/manifest.ts +++ b/src/utils/manifest.ts @@ -96,13 +96,6 @@ export const buildManifest = (sources: Source[], extractors: Extractor[], config default: config['proxyConfig'] ?? '', }); - manifest.config.push({ - key: 'noCache', - type: 'checkbox', - title: 'Disable cache', - ...('noCache' in config && { default: 'checked' }), - }); - extractors.forEach((extractor) => { if (extractor.id === 'external') { return;