Discord Player

BaseExtractor

Minimal v7 lifecycle and source API, adapted to the source operation registry.

You are reading the v8 docsDev
ClassTypeScript@discord-player/plugin-host
View sourcepackages/plugin-host/src/compat/base-extractor.ts:11
class BaseExtractor<Options extends object = object>

Minimal v7 lifecycle and source API, adapted to the source operation registry.

Constructors

constructor

constructor<Options extends object = object>(
  context: ExtractorExecutionContext,
  options: Options = ...,
)

Create a compatibility instance; use player.extractors.register to own it.

Parameters

NameTypeDescription
contextExtractorExecutionContext

Owning compatibility context.

optionsOptionsDefault: ...

Original extractor options.

Properties

priority

priority: number

Higher priority wins before match confidence.

protocols

protocols: string[]

Supported explicit query protocols.

context

Owning legacy registration context.

options

options: Options

Original local extractor configuration.

Accessors

identifierreadonly

readonly get identifier(): string

Subclass static identifier.

Returns

string

supportsDemuxreadonly

readonly get supportsDemux(): boolean

Obsolete demux support is unavailable.

Returns

boolean

Methods

resolveLyricsoptional

resolveLyrics(
  input: string | Track<unknown>,
): Promise<LyricsResult | LyricsResult[] | null>

Optional lyrics capability, adapted into the shared operation dispatcher.

Parameters

NameTypeDescription
inputstring | Track<unknown>

Track metadata or a raw lookup query.

Returns

Promise<LyricsResult | LyricsResult[] | null>

Lyrics records, or null when no lyrics were found.

activate

activate(): Promise<void>

Acquire extractor resources.

Returns

Promise<void>

deactivate

deactivate(): Promise<void>

Release extractor resources.

Returns

Promise<void>

reconfigure

reconfigure(options: Options): Promise<void>

Recreate the owned registration with new options.

Parameters

NameTypeDescription
optionsOptions

Replacement options.

Returns

Promise<void>

validate

validate(query: string, type?: string | null): Promise<boolean>

Test whether this extractor accepts a query.

Parameters

NameTypeDescription
querystring

Search text.

type?string | null

Query hint.

Returns

Promise<boolean>

handle

handle(query: string, context: ExtractorSearchContext): Promise<SearchResultData>

Resolve metadata.

Parameters

NameTypeDescription
querystring

Search text.

contextExtractorSearchContext

Search hints.

Returns

Promise<SearchResultData>

stream

stream(track: Track): Promise<ExtractorStreamable | undefined>

Resolve media, or decline to enable bridging.

Parameters

NameTypeDescription
trackTrack

Track to stream.

Returns

Promise<ExtractorStreamable | undefined>

getRelatedTracks

getRelatedTracks(track: Track, history?: unknown): Promise<SearchResultData>

Resolve related metadata.

Parameters

NameTypeDescription
trackTrack

Seed track.

history?unknown

Optional queue history; local execution only.

Returns

Promise<SearchResultData>

bridge

bridge(
  track: Track,
  sourceExtractor: BaseExtractor<any> | null,
): Promise<ExtractorStreamable | null>

Explicit fallback for another source.

Parameters

NameTypeDescription
trackTrack

Track needing a stream.

sourceExtractorBaseExtractor<any> | null

Original extractor, if legacy.

Returns

Promise<ExtractorStreamable | null>

handlePostStream

handlePostStream(stream: Readable, next: NextFunction): void

Transform an encoded local Readable. Raw codec overrides are unsupported.

Parameters

NameTypeDescription
streamReadable

Encoded input.

nextNextFunction

Completion callback.

Returns

void

createBridgeQuery

createBridgeQuery(track: Track): string

Build an anonymous bridge query.

Parameters

NameTypeDescription
trackTrack

Track metadata.

Returns

string

createResponse

createResponse(
  playlist: Playlist | null = null,
  tracks: Track<unknown>[] = ...,
): SearchResultData

Construct a metadata response.

Parameters

NameTypeDescription
playlistPlaylist | nullDefault: null

Optional playlist.

tracksTrack<unknown>[]Default: ...

Ordered tracks, defaulting to playlist entries.

Returns

SearchResultData

debug

debug(message: string): void

Publish a diagnostic.

Parameters

NameTypeDescription
messagestring

Diagnostic text.

Returns

void

emit

emit<K extends keyof SourceRuntimeEvents>(
  event: K,
  ...args: SourceRuntimeEvents[K],
): boolean

Forward supported Player events.

Parameters

NameTypeDescription
eventK

Player event.

...argsSourceRuntimeEvents[K]

Event arguments.

Returns

boolean

Static properties

identifierstatic

static identifier: string

Default identifier; subclasses should override.

On this page