From f0dcba4606ab9d6454dfd170b2134cc58e2b35c1 Mon Sep 17 00:00:00 2001 From: TheTank Date: Wed, 4 Feb 2026 15:20:42 -0500 Subject: [PATCH] Add runAllConcurrent to ProviderControls --- src/entrypoint/controls.ts | 13 ++++++++++++- src/runners/runner.ts | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/entrypoint/controls.ts b/src/entrypoint/controls.ts index 6599f28..dc33c63 100644 --- a/src/entrypoint/controls.ts +++ b/src/entrypoint/controls.ts @@ -6,7 +6,7 @@ import { makeFetcher } from '@/fetchers/common'; import { Fetcher } from '@/fetchers/types'; import { Embed, EmbedOutput, Sourcerer, SourcererOutput } from '@/providers/base'; import { scrapeIndividualEmbed, scrapeInvidualSource } from '@/runners/individualRunner'; -import { RunOutput, runAllProviders } from '@/runners/runner'; +import { RunOutput, runAllProviders, runAllProvidersConcurrent } from '@/runners/runner'; export interface ProviderControlsInput { fetcher: Fetcher; @@ -15,6 +15,7 @@ export interface ProviderControlsInput { sources: Sourcerer[]; embeds: Embed[]; proxyStreams?: boolean; // temporary + concurrency?: number; } export interface RunnerOptions { @@ -72,6 +73,9 @@ export interface ProviderControls { // returns the stream, or null if none found runAll(runnerOps: RunnerOptions): Promise; + // Run all providers concurrently. in order of rank (highest first) + runAllConcurrent(runnerOps: RunnerOptions): Promise; + // Run a specific source scraper runSourceScraper(runnerOps: SourceRunnerOptions): Promise; @@ -99,6 +103,7 @@ export function makeControls(ops: ProviderControlsInput): ProviderControls { fetcher: makeFetcher(ops.fetcher), proxiedFetcher: makeFetcher(ops.proxiedFetcher ?? ops.fetcher), proxyStreams: ops.proxyStreams, + concurrency: ops.concurrency ?? 3, // default to 3 workers }; return { @@ -108,6 +113,12 @@ export function makeControls(ops: ProviderControlsInput): ProviderControls { ...runnerOps, }); }, + runAllConcurrent(runnerOps) { + return runAllProvidersConcurrent(list, { + ...providerRunnerOps, + ...runnerOps, + }); + }, runSourceScraper(runnerOps) { return scrapeInvidualSource(list, { ...providerRunnerOps, diff --git a/src/runners/runner.ts b/src/runners/runner.ts index e412225..dde42b9 100644 --- a/src/runners/runner.ts +++ b/src/runners/runner.ts @@ -204,7 +204,7 @@ export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOpt } export async function runAllProvidersConcurrent(list: ProviderList, ops: ProviderRunnerOptions): Promise { - const concurrency = ops.concurrency ?? 3; // default to 3 workers + const concurrency = ops.concurrency ?? 3; const sources = reorderOnIdList(ops.sourceOrder ?? [], list.sources).filter((source) => { if (ops.media.type === 'movie') return !!source.scrapeMovie;