InfoExtractorPlugin
This plugin only can extract the info from supported links, but not play song directly from its source
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new InfoExtractorPlugin(): InfoExtractorPlugin;Returns
Section titled “Returns”InfoExtractorPlugin
Inherited from
Section titled “Inherited from”Properties
Section titled “Properties”aliases?
Section titled “aliases?”readonly aliases?: string[];Additional identifiers of the source of the plugin, e.g. ["yt"].
Inherited from
Section titled “Inherited from”distube
Section titled “distube”distube: DisTube;DisTube
Inherited from
Section titled “Inherited from”playable
Section titled “playable”readonly playable: false = false;The songs of this plugin are resolved to a playable version by another plugin.
Overrides
Section titled “Overrides”source?
Section titled “source?”readonly source?: string;The identifier of the source of the plugin.
It defaults to the name of the class, lowercased, without the Plugin
suffix (MyPlugin -> myplugin).
It is used to route a search to a plugin, and to find a plugin with DisTube#getPlugin.
Inherited from
Section titled “Inherited from”readonly type: PluginType = PluginType.INFO_EXTRACTOR;The type of the plugin.
Overrides
Section titled “Overrides”Accessors
Section titled “Accessors”identifiers
Section titled “identifiers”Get Signature
Section titled “Get Signature”get identifiers(): string[];Every identifier of this plugin: its Plugin.source and its Plugin.aliases, lowercased.
The static properties of the class are used when the instance ones are not defined, so a plugin can declare them either way.
Returns
Section titled “Returns”string[]
Inherited from
Section titled “Inherited from”streams
Section titled “streams”Get Signature
Section titled “Get Signature”get streams(): StreamServer;The local HTTP server of the DisTube instance.
Register a handler on it when the plugin cannot hand out a static URL to FFmpeg, instead of running its own server.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”createSearchQuery()
Section titled “createSearchQuery()”abstract createSearchQuery<T>(song): Awaitable<string>;Create a search query to be used in ExtractorPlugin#searchSong
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”Song<T>
Input song
Returns
Section titled “Returns”Awaitable<string>
The search query
Overrides
Section titled “Overrides”ExtractorPlugin.createSearchQuery
destroy()
Section titled “destroy()”destroy(): void | Promise<void>;Destroy the plugin.
It is called when the DisTube instance is destroyed. Override it to release every resource held by the plugin (HTTP servers, timers, browser sessions, …).
Returns
Section titled “Returns”void | Promise<void>
Nothing, or a promise that resolves when the plugin is destroyed
Inherited from
Section titled “Inherited from”getRelatedSongs()
Section titled “getRelatedSongs()”getRelatedSongs(_song): Awaitable<Song<unknown>[]>;Get related songs from a supported url.
Override it to enable the autoplay for your source. Return an empty array when your source does not have any related songs.
Parameters
Section titled “Parameters”Input song
Returns
Section titled “Returns”The related songs
Inherited from
Section titled “Inherited from”ExtractorPlugin.getRelatedSongs
getStreamURL()
Section titled “getStreamURL()”getStreamURL<T>(_song): Promise<string>;This plugin cannot play the songs it resolves, so it never has a stream url.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”Song<T>
Input song
Returns
Section titled “Returns”Promise<string>
Nothing: it always throws
Throws
Section titled “Throws”PluginError Always, with the code NO_STREAM
Overrides
Section titled “Overrides”init()
Section titled “init()”init(distube): void | Promise<void>;Initialize the plugin.
It can be asynchronous: use DisTube.create to wait for the initialization of the plugins.
Parameters
Section titled “Parameters”distube
Section titled “distube”The DisTube instance
Returns
Section titled “Returns”void | Promise<void>
Nothing, or a promise that resolves when the plugin is initialized
Example
Section titled “Example”override async init(distube: DisTube) { this.client = await createSession();}Inherited from
Section titled “Inherited from”resolve()
Section titled “resolve()”abstract resolve<T>(url, options): Awaitable< | Song<T>| Playlist<T>>;Resolve the validated url to a Song or a Playlist.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”string
URL
options
Section titled “options”Optional options
Returns
Section titled “Returns”Awaitable<
| Song<T>
| Playlist<T>>
The resolved song or playlist
Overrides
Section titled “Overrides”search()
Section titled “search()”search<T>(query, options?): Promise<SearchResult<T>>;Search for the songs of the source.
The default implementation returns the single result of Plugin#searchSong. Override it to return more results, or to return a playlist.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”string
Search query
options?
Section titled “options?”SearchOptions<T> = {}
Optional options
Returns
Section titled “Returns”Promise<SearchResult<T>>
The result of the search
Example
Section titled “Example”const result = await plugin.search("Never gonna give you up", { limit: 5 });Inherited from
Section titled “Inherited from”searchSong()
Section titled “searchSong()”searchSong<T>(_query, _options): Awaitable<Song<T> | null>;Search for a song of the source.
Override it to enable the search of your source. It returns null by
default, because a source that cannot be searched does not have any result.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”_query
Section titled “_query”string
Search query
_options
Section titled “_options”Optional options
Returns
Section titled “Returns”The song that was found, or null
Example
Section titled “Example”override async searchSong(query: string): Promise<Song | null> { return findSong(query);}Inherited from
Section titled “Inherited from”validate()
Section titled “validate()”abstract validate(url): Awaitable<boolean>;Check if the url is working with this plugin
Parameters
Section titled “Parameters”string
Input url
Returns
Section titled “Returns”Awaitable<boolean>
true when the plugin can handle the url