diff --git a/package-lock.json b/package-lock.json index 1258baca..8afeb5ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8744,6 +8744,7 @@ "@aiostreams/addon": "^1.0.0", "@aiostreams/formatters": "^1.0.0", "@aiostreams/types": "^1.0.0", + "@aiostreams/wrappers": "^1.0.0", "next": "15.1.2", "react": "^19.0.0", "react-dom": "^19.0.0", @@ -8774,7 +8775,6 @@ "name": "@aiostreams/wrappers", "version": "1.3.1", "devDependencies": { - "@aiostreams/addon": "^1.0.0", "@aiostreams/parser": "^1.0.0", "@aiostreams/types": "^1.0.0" } diff --git a/packages/addon/src/config.ts b/packages/addon/src/config.ts index 6a34f057..687a8b86 100644 --- a/packages/addon/src/config.ts +++ b/packages/addon/src/config.ts @@ -1,237 +1,11 @@ -import { Config } from '@aiostreams/types'; -import { AddonDetail } from '@aiostreams/types'; +import { AddonDetail, Config } from '@aiostreams/types'; +import { addonDetails } from '@aiostreams/wrappers'; export const allowedFormatters = ['gdrive', 'torrentio', 'torbox']; -export const allowedAddons = ['torrentio', 'comet', 'torbox', 'gdrive', 'custom']; export const MAX_ADDONS = 10; export const MAX_SIZE = 150000000000; // 1500GB -const MAX_TIMEOUT = 20000; -const MIN_TIMEOUT = 1000; -export const addonDetails: AddonDetail[] = [ - { - name: 'Torrentio', - id: 'torrentio', - requiresService: false, - supportedServices: ['realdebrid', 'alldebrid', 'premiumize', 'debridlink', 'torbox', 'offcloud', 'putio'], - options: [ - { - id: 'overrideName', - required: false, - label: 'Override Addon Name', - description: 'Override the name of the Torrentio addon that shows up in the results', - type: 'text', - }, - { - id: 'overrideUrl', - required: false, - label: 'Override URL', - description: - 'Override the URL used to fetch streams from the torrentio addon. This option is incompatible with the useMultipleInstances option. By default, the URL is generated based on the selected services and their credentials. Use this option to override the URL with a custom URL.', - type: 'text', - }, - { - id: 'useMultipleInstances', - required: false, - label: 'Use Multiple Instances', - description: - 'Use multiple instances of the torrentio addon to fetch streams when using multiple services. With this option enabled, when you use multiple services, a separate request is made for each service. I recommend leaving this disabled, unless you want duplicate streams but with different services.', - type: 'checkbox', - }, - { - id: 'indexerTimeout', - required: false, - label: 'Override Indexer Timeout', - description: 'The timeout for fetching streams from the Torrentio addon. This is the time in milliseconds that the addon will wait for a response before timing out. Leave it empty to use the recommended timeout.', - type: 'number', - constraints: { - min: MIN_TIMEOUT, - max: MAX_TIMEOUT - } - }, - - ], - }, - { - name: 'Comet', - id: 'comet', - requiresService: true, - supportedServices: ['realdebrid', 'alldebrid', 'premiumize', 'debridlink', 'torbox'], - options: [ - { - id: 'prioritiseDebrid', - required: false, - label: 'Prioritise Debrid Service', - description: - 'Prioritise a specific debrid service when fetching streams. This option is useful when you want to use a specific debrid service for fetching streams. By default, the addon will make a separate request for each debrid service. I highly recommend provding a value for this option as it will speed up the fetching process and remove redundant results.', - type: 'select', - options: [{ value: 'realdebrid', label: 'Real Debrid' }, { value: 'alldebrid', label: 'All Debrid' }, { value: 'premiumize', label: 'Premiumize' }, { value: 'debridlink', label: 'Debrid Link' }, { value: 'torbox', label: 'Torbox' }], - }, - { - id: 'overrideName', - required: false, - label: 'Override Addon Name', - description: 'Override the name of the Comet addon that shows up in the results', - type: 'text', - }, - { - id: 'overrideUrl', - required: false, - label: 'Override URL', - description: - 'Override the URL used to fetch streams from the Comet addon. This option is incompatible with the prioritiseDebrid option. By default, the URL is generated based on the selected services and their credentials. Use this option to override the URL with a custom URL.', - type: 'text', - }, - { - id: 'indexerTimeout', - required: false, - label: 'Override Indexer Timeout', - description: 'The timeout for fetching streams from the Comet addon. This is the time in milliseconds that the addon will wait for a response before timing out. Leave it empty to use the recommended timeout.', - type: 'number', - constraints: { - min: MIN_TIMEOUT, - max: MAX_TIMEOUT - } - } - ] - }, - { - name: 'MediaFusion', - id: 'mediafusion', - requiresService: false, - supportedServices: ['realdebrid', 'alldebrid', 'premiumize', 'debridlink', 'torbox', 'offcloud'], - options: [ - { - id: 'prioritiseDebrid', - required: false, - label: 'Prioritise Debrid Service', - description: - 'Prioritise a specific debrid service when fetching streams. This option is useful when you want to use a specific debrid service for fetching streams. By default, the addon will make a separate request for each debrid service. I highly recommend provding a value for this option as it will speed up the fetching process and remove redundant results.', - type: 'select', - options: [{ value: 'realdebrid', label: 'Real Debrid' }, { value: 'alldebrid', label: 'All Debrid' }, { value: 'premiumize', label: 'Premiumize' }, { value: 'debridlink', label: 'Debrid Link' }, { value: 'torbox', label: 'Torbox' }, { value: 'offcloud', label: 'Offcloud' }], - }, - { - id: 'overrideName', - required: false, - label: 'Override Addon Name', - description: 'Override the name of the Media Fusion addon that shows up in the results', - type: 'text', - }, - { - id: 'overrideUrl', - required: false, - label: 'Override URL', - description: - 'Override the URL used to fetch streams from the Media Fusion addon. This option is incompatible with the prioritiseDebrid option. By default, the URL is generated based on the selected services and their credentials. Use this option to override the URL with a custom URL.', - type: 'text', - }, - { - id: 'indexerTimeout', - required: false, - label: 'Override Indexer Timeout', - description: 'The timeout for fetching streams from the Media Fusion addon. This is the time in milliseconds that the addon will wait for a response before timing out. Leave it empty to use the recommended timeout.', - type: 'number', - constraints: { - min: 1000, - max: 20000 - } - } - ] - }, - { - name: 'Torbox', - id: 'torbox', - requiresService: true, - supportedServices: ['torbox'], - options: [ - { - id: 'indexerTimeout', - required: false, - label: 'Override Indexer Timeout', - description: 'The timeout for fetching streams from the Torbox addon. This is the time in milliseconds that the addon will wait for a response from Torbox before timing out. Leave it empty to use the recommended timeout.', - type: 'number', - constraints: { - min: 1000, - max: 20000 - } - }, - { - id: 'overrideName', - required: false, - label: 'Override Addon Name', - description: 'Override the name of the addon that shows up in the results. Leave it empty to use the default name of \'Torbox\'.', - type: 'text', - } - ], - }, - { - name: 'Google Drive (Viren070)', - id: 'gdrive', - requiresService: false, - supportedServices: [], - options: [ - { - id: 'addonUrl', - required: true, - label: 'Addon URL', - description: 'The URL to the manifest.json file for your Google Drive addon. This would be the URL of your Cloudflare Worker which looks something like https://your-worker-name.your-subdomain.workers.dev/manifest.json', - type: 'text', - }, - { - id: 'overrideName', - required: false, - label: 'Override Addon Name', - description: 'Override the name of the addon that shows up in the results. Leave it empty to use the default name of \'GDrive\'.', - type: 'text', - }, - { - id: 'indexerTimeout', - required: false, - label: 'Override Indexer Timeout', - description: 'The timeout for fetching streams from the Google Drive addon in milliseconds. This is the time in milliseconds that the addon will wait for a response from your Cloudflare Worker before timing out. Leave it empty to use the recommended timeout.', - type: 'number', - constraints: { - min: 1000, - max: 20000 - } - } - ], - }, - { - name: 'Custom', - id: 'custom', - requiresService: false, - supportedServices: [], - options: [ - { - id: 'name', - required: true, - description: 'The name of the custom addon. This is the name that will show up in the results', - label: 'Name', - type: 'text', - }, - { - id: 'url', - required: true, - description: 'The URL of the custom addon. This is the URL that will be used to fetch streams from the custom addon. The URL should point to the manifest.json file of the custom addon', - label: 'URL', - type: 'text', - }, - { - id: 'indexerTimeout', - required: false, - label: 'Override Indexer Timeout', - description: 'The timeout for fetching streams from the custom addon in milliseconds', - type: 'number', - constraints: { - min: 1000, - max: 20000 - } - } - ], - }, -]; export const allowedLanguages = [ 'English', @@ -435,7 +209,7 @@ export function validateConfig(config: Config): { ); } } - const details = addonDetails.find((detail) => detail.id === addon.id); + const details = addonDetails.find((detail: AddonDetail) => detail.id === addon.id); if (!details) { return createResponse( false, diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 82fe9299..bdad1190 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -12,6 +12,7 @@ "@aiostreams/types": "^1.0.0", "@aiostreams/formatters": "^1.0.0", "@aiostreams/addon": "^1.0.0", + "@aiostreams/wrappers": "^1.0.0", "next": "15.1.2", "react": "^19.0.0", "react-dom": "^19.0.0", diff --git a/packages/frontend/src/app/configure/page.tsx b/packages/frontend/src/app/configure/page.tsx index f898f1c6..ab72b6e9 100644 --- a/packages/frontend/src/app/configure/page.tsx +++ b/packages/frontend/src/app/configure/page.tsx @@ -19,14 +19,13 @@ import { Slide, ToastContainer, toast } from 'react-toastify'; import addonPackage from '../../../package.json'; import { formatSize } from '@aiostreams/formatters'; import { - allowedAddons, allowedFormatters, allowedLanguages, - addonDetails, validateConfig, serviceCredentials, MAX_SIZE, } from '@aiostreams/config'; +import { addonDetails } from '@aiostreams/wrappers'; const version = addonPackage.version; @@ -323,7 +322,7 @@ export default function Configure() { if (!addons) { return []; } - return addons.filter((addon) => allowedAddons.includes(addon.id)); + return addons.filter((addon) => addonDetails.some((detail) => detail.id === addon.id)); }; // Load config from the window path if it exists diff --git a/packages/frontend/tsconfig.json b/packages/frontend/tsconfig.json index e317368d..ad391315 100644 --- a/packages/frontend/tsconfig.json +++ b/packages/frontend/tsconfig.json @@ -31,6 +31,9 @@ }, { "path": "../formatters" + }, + { + "path": "../wrappers" } ], "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], diff --git a/packages/wrappers/package.json b/packages/wrappers/package.json index cdb9491d..f40614d2 100644 --- a/packages/wrappers/package.json +++ b/packages/wrappers/package.json @@ -9,7 +9,6 @@ "description": "Library with wrappers for different addons", "devDependencies": { "@aiostreams/parser": "^1.0.0", - "@aiostreams/types": "^1.0.0", - "@aiostreams/addon": "^1.0.0" + "@aiostreams/types": "^1.0.0" } } diff --git a/packages/wrappers/src/comet.ts b/packages/wrappers/src/comet.ts index e4a1874b..a4121289 100644 --- a/packages/wrappers/src/comet.ts +++ b/packages/wrappers/src/comet.ts @@ -1,8 +1,8 @@ -import { ParsedNameData, StreamRequest } from '@aiostreams/types'; +import { AddonDetail, ParsedNameData, StreamRequest } from '@aiostreams/types'; import { parseFilename, extractSizeInBytes } from '@aiostreams/parser'; import { ParsedStream, Stream, Config } from '@aiostreams/types'; import { BaseWrapper } from './base'; -import { addonDetails } from '@aiostreams/addon'; +import { addonDetails } from './details'; interface CometStream extends Stream { torrentTitle?: string; @@ -102,7 +102,7 @@ export async function getCometStreams( }, streamRequest: StreamRequest ): Promise { - const supportedServices: string[] = addonDetails.find((addon) => addon.id === 'comet')?.supportedServices || []; + const supportedServices: string[] = addonDetails.find((addon: AddonDetail) => addon.id === 'comet')?.supportedServices || []; const parsedStreams: ParsedStream[] = []; const indexerTimeout = cometOptions.indexerTimeout ? parseInt(cometOptions.indexerTimeout) : undefined; diff --git a/packages/wrappers/src/details.ts b/packages/wrappers/src/details.ts new file mode 100644 index 00000000..b561c17a --- /dev/null +++ b/packages/wrappers/src/details.ts @@ -0,0 +1,228 @@ +import { AddonDetail } from "@aiostreams/types"; + +const MAX_TIMEOUT = 20000; +const MIN_TIMEOUT = 1000; + +export const addonDetails: AddonDetail[] = [ + { + name: 'Torrentio', + id: 'torrentio', + requiresService: false, + supportedServices: ['realdebrid', 'alldebrid', 'premiumize', 'debridlink', 'torbox', 'offcloud', 'putio'], + options: [ + { + id: 'overrideName', + required: false, + label: 'Override Addon Name', + description: 'Override the name of the Torrentio addon that shows up in the results', + type: 'text', + }, + { + id: 'overrideUrl', + required: false, + label: 'Override URL', + description: + 'Override the URL used to fetch streams from the torrentio addon. This option is incompatible with the useMultipleInstances option. By default, the URL is generated based on the selected services and their credentials. Use this option to override the URL with a custom URL.', + type: 'text', + }, + { + id: 'useMultipleInstances', + required: false, + label: 'Use Multiple Instances', + description: + 'Use multiple instances of the torrentio addon to fetch streams when using multiple services. With this option enabled, when you use multiple services, a separate request is made for each service. I recommend leaving this disabled, unless you want duplicate streams but with different services.', + type: 'checkbox', + }, + { + id: 'indexerTimeout', + required: false, + label: 'Override Indexer Timeout', + description: 'The timeout for fetching streams from the Torrentio addon. This is the time in milliseconds that the addon will wait for a response before timing out. Leave it empty to use the recommended timeout.', + type: 'number', + constraints: { + min: MIN_TIMEOUT, + max: MAX_TIMEOUT + } + }, + + ], + }, + { + name: 'Comet', + id: 'comet', + requiresService: true, + supportedServices: ['realdebrid', 'alldebrid', 'premiumize', 'debridlink', 'torbox'], + options: [ + { + id: 'prioritiseDebrid', + required: false, + label: 'Prioritise Debrid Service', + description: + 'Prioritise a specific debrid service when fetching streams. This option is useful when you want to use a specific debrid service for fetching streams. By default, the addon will make a separate request for each debrid service. I highly recommend provding a value for this option as it will speed up the fetching process and remove redundant results.', + type: 'select', + options: [{ value: 'realdebrid', label: 'Real Debrid' }, { value: 'alldebrid', label: 'All Debrid' }, { value: 'premiumize', label: 'Premiumize' }, { value: 'debridlink', label: 'Debrid Link' }, { value: 'torbox', label: 'Torbox' }], + }, + { + id: 'overrideName', + required: false, + label: 'Override Addon Name', + description: 'Override the name of the Comet addon that shows up in the results', + type: 'text', + }, + { + id: 'overrideUrl', + required: false, + label: 'Override URL', + description: + 'Override the URL used to fetch streams from the Comet addon. This option is incompatible with the prioritiseDebrid option. By default, the URL is generated based on the selected services and their credentials. Use this option to override the URL with a custom URL.', + type: 'text', + }, + { + id: 'indexerTimeout', + required: false, + label: 'Override Indexer Timeout', + description: 'The timeout for fetching streams from the Comet addon. This is the time in milliseconds that the addon will wait for a response before timing out. Leave it empty to use the recommended timeout.', + type: 'number', + constraints: { + min: MIN_TIMEOUT, + max: MAX_TIMEOUT + } + } + ] + }, + { + name: 'MediaFusion', + id: 'mediafusion', + requiresService: false, + supportedServices: ['realdebrid', 'alldebrid', 'premiumize', 'debridlink', 'torbox', 'offcloud'], + options: [ + { + id: 'prioritiseDebrid', + required: false, + label: 'Prioritise Debrid Service', + description: + 'Prioritise a specific debrid service when fetching streams. This option is useful when you want to use a specific debrid service for fetching streams. By default, the addon will make a separate request for each debrid service. I highly recommend provding a value for this option as it will speed up the fetching process and remove redundant results.', + type: 'select', + options: [{ value: 'realdebrid', label: 'Real Debrid' }, { value: 'alldebrid', label: 'All Debrid' }, { value: 'premiumize', label: 'Premiumize' }, { value: 'debridlink', label: 'Debrid Link' }, { value: 'torbox', label: 'Torbox' }, { value: 'offcloud', label: 'Offcloud' }], + }, + { + id: 'overrideName', + required: false, + label: 'Override Addon Name', + description: 'Override the name of the Media Fusion addon that shows up in the results', + type: 'text', + }, + { + id: 'overrideUrl', + required: false, + label: 'Override URL', + description: + 'Override the URL used to fetch streams from the Media Fusion addon. This option is incompatible with the prioritiseDebrid option. By default, the URL is generated based on the selected services and their credentials. Use this option to override the URL with a custom URL.', + type: 'text', + }, + { + id: 'indexerTimeout', + required: false, + label: 'Override Indexer Timeout', + description: 'The timeout for fetching streams from the Media Fusion addon. This is the time in milliseconds that the addon will wait for a response before timing out. Leave it empty to use the recommended timeout.', + type: 'number', + constraints: { + min: MIN_TIMEOUT, + max: MAX_TIMEOUT + } + } + ] + }, + { + name: 'Torbox', + id: 'torbox', + requiresService: true, + supportedServices: ['torbox'], + options: [ + { + id: 'indexerTimeout', + required: false, + label: 'Override Indexer Timeout', + description: 'The timeout for fetching streams from the Torbox addon. This is the time in milliseconds that the addon will wait for a response from Torbox before timing out. Leave it empty to use the recommended timeout.', + type: 'number', + constraints: { + min: MIN_TIMEOUT, + max: MAX_TIMEOUT + } + }, + { + id: 'overrideName', + required: false, + label: 'Override Addon Name', + description: 'Override the name of the addon that shows up in the results. Leave it empty to use the default name of \'Torbox\'.', + type: 'text', + } + ], + }, + { + name: 'Google Drive (Viren070)', + id: 'gdrive', + requiresService: false, + supportedServices: [], + options: [ + { + id: 'addonUrl', + required: true, + label: 'Addon URL', + description: 'The URL to the manifest.json file for your Google Drive addon. This would be the URL of your Cloudflare Worker which looks something like https://your-worker-name.your-subdomain.workers.dev/manifest.json', + type: 'text', + }, + { + id: 'overrideName', + required: false, + label: 'Override Addon Name', + description: 'Override the name of the addon that shows up in the results. Leave it empty to use the default name of \'GDrive\'.', + type: 'text', + }, + { + id: 'indexerTimeout', + required: false, + label: 'Override Indexer Timeout', + description: 'The timeout for fetching streams from the Google Drive addon in milliseconds. This is the time in milliseconds that the addon will wait for a response from your Cloudflare Worker before timing out. Leave it empty to use the recommended timeout.', + type: 'number', + constraints: { + min: MIN_TIMEOUT, + max: MAX_TIMEOUT + } + } + ], + }, + { + name: 'Custom', + id: 'custom', + requiresService: false, + supportedServices: [], + options: [ + { + id: 'name', + required: true, + description: 'The name of the custom addon. This is the name that will show up in the results', + label: 'Name', + type: 'text', + }, + { + id: 'url', + required: true, + description: 'The URL of the custom addon. This is the URL that will be used to fetch streams from the custom addon. The URL should point to the manifest.json file of the custom addon', + label: 'URL', + type: 'text', + }, + { + id: 'indexerTimeout', + required: false, + label: 'Override Indexer Timeout', + description: 'The timeout for fetching streams from the custom addon in milliseconds', + type: 'number', + constraints: { + min: MIN_TIMEOUT, + max: MAX_TIMEOUT + } + } + ], + }, +]; \ No newline at end of file diff --git a/packages/wrappers/src/index.ts b/packages/wrappers/src/index.ts index 5cf9e24e..d1bce428 100644 --- a/packages/wrappers/src/index.ts +++ b/packages/wrappers/src/index.ts @@ -1,3 +1,4 @@ +export * from './details'; export * from './base'; export * from './torbox'; export * from './torrentio'; diff --git a/packages/wrappers/src/mediafusion.ts b/packages/wrappers/src/mediafusion.ts index 5bff6a00..d0949d66 100644 --- a/packages/wrappers/src/mediafusion.ts +++ b/packages/wrappers/src/mediafusion.ts @@ -1,8 +1,8 @@ -import { ParsedNameData, StreamRequest } from '@aiostreams/types'; +import { AddonDetail, ParsedNameData, StreamRequest } from '@aiostreams/types'; import { parseFilename, extractSizeInBytes } from '@aiostreams/parser'; import { ParsedStream, Stream, Config } from '@aiostreams/types'; import { BaseWrapper } from './base'; -import { addonDetails } from '@aiostreams/addon'; +import { addonDetails } from './details'; export class MediaFusion extends BaseWrapper { @@ -83,7 +83,7 @@ export async function getMediafusionStreams( }, streamRequest: StreamRequest ): Promise { - const supportedServices: string[] = addonDetails.find((addon) => addon.id === 'mediafusion')?.supportedServices || []; + const supportedServices: string[] = addonDetails.find((addon: AddonDetail) => addon.id === 'mediafusion')?.supportedServices || []; const parsedStreams: ParsedStream[] = []; const indexerTimeout = mediafusionOptions.indexerTimeout ? parseInt(mediafusionOptions.indexerTimeout) : undefined; diff --git a/packages/wrappers/src/torrentio.ts b/packages/wrappers/src/torrentio.ts index 2bc9fd37..8a1ee8ba 100644 --- a/packages/wrappers/src/torrentio.ts +++ b/packages/wrappers/src/torrentio.ts @@ -1,8 +1,8 @@ -import { ParsedNameData, StreamRequest } from '@aiostreams/types'; +import { AddonDetail, ParsedNameData, StreamRequest } from '@aiostreams/types'; import { parseFilename, extractSizeInBytes } from '@aiostreams/parser'; import { ParsedStream, Stream, Config } from '@aiostreams/types'; import { BaseWrapper } from './base'; -import { addonDetails } from '@aiostreams/addon'; +import { addonDetails } from './details'; export class Torrentio extends BaseWrapper { constructor(configString: string | null, overrideUrl: string | null, indexerTimeout: number = 10000, addonName: string = 'Torrentio') { @@ -71,7 +71,7 @@ export async function getTorrentioStreams( }, streamRequest: StreamRequest ): Promise { - const supportedServices: string[] = addonDetails.find((addon) => addon.id === 'torrentio')?.supportedServices || []; + const supportedServices: string[] = addonDetails.find((addon: AddonDetail) => addon.id === 'torrentio')?.supportedServices || []; const parsedStreams: ParsedStream[] = []; const indexerTimeout = torrentioOptions.indexerTimeout ? parseInt(torrentioOptions.indexerTimeout) : undefined; diff --git a/packages/wrappers/tsconfig.json b/packages/wrappers/tsconfig.json index 6f6c6d7b..ecd8ec57 100644 --- a/packages/wrappers/tsconfig.json +++ b/packages/wrappers/tsconfig.json @@ -12,9 +12,6 @@ }, { "path": "../types" - }, - { - "path": "../addon" } ] }