Skip to content

Commit

Permalink
fix: remove interdependency and other improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Viren070 committed Dec 30, 2024
1 parent 2a1f3fb commit 52f5571
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 247 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

232 changes: 3 additions & 229 deletions packages/addon/src/config.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions packages/frontend/src/app/configure/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions packages/frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
},
{
"path": "../formatters"
},
{
"path": "../wrappers"
}
],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
Expand Down
3 changes: 1 addition & 2 deletions packages/wrappers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
6 changes: 3 additions & 3 deletions packages/wrappers/src/comet.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -102,7 +102,7 @@ export async function getCometStreams(
},
streamRequest: StreamRequest
): Promise<ParsedStream[]> {
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;

Expand Down
Loading

0 comments on commit 52f5571

Please sign in to comment.