Options
All
  • Public
  • Public/Protected
  • All
Menu

play-dl

Index

Type Aliases

Shared type for Deezer tracks, playlists and albums

Type of SoundCloud

type for Spotify Classes

Type for YouTube returns

YouTubeStream: Stream | LiveStream | SeekStream

Type for YouTube Stream

Functions

  • authorization(): void
  • Authorization interface for Spotify, SoundCloud and YouTube.

    Either stores info in .data folder or shows relevant data to be used in setToken function.

    const play = require('play-dl')

    play.authorization()

    Just run the above command and you will get a interface asking some questions.

    Returns void

  • decipher_info<T>(data: T, audio_only?: boolean): Promise<T>
  • deezer(url: string): Promise<Deezer>
  • Searches Deezer for tracks using the specified metadata.

    Parameters

    • options: DeezerAdvancedSearchOptions

      The metadata and limit for the search

      • limit?: The maximum number of results to return, maximum 100, defaults to 10.
      • artist?: The name of the artist
      • album?: The title of the album
      • title?: The title of the track
      • label?: The label that released the track
      • minDurationInSec?: The minimum duration in seconds
      • maxDurationInSec?: The maximum duration in seconds
      • minBpm?: The minimum BPM
      • maxBpm?: The minimum BPM

    Returns Promise<DeezerTrack[]>

    An array of tracks matching the metadata

  • dz_validate(url: string): Promise<"track" | "playlist" | "album" | "search" | false>
  • Validates a Deezer URL

    Parameters

    • url: string

      The URL to validate

    Returns Promise<"track" | "playlist" | "album" | "search" | false>

    The type of the URL either 'track', 'playlist', 'album', 'search' or false. false means that the provided URL was a wrongly formatted or an unsupported Deezer URL.

  • extractID(url: string): string
  • Extract ID of YouTube url.

    Parameters

    • url: string

      ID or url of YouTube

    Returns string

    ID of video or playlist.

  • getFreeClientID(): Promise<string>
  • Gets Free SoundCloud Client ID.

    Use this in beginning of your code to add SoundCloud support.

    play.getFreeClientID().then((clientID) => play.setToken({
    soundcloud : {
    client_id : clientID
    }
    }))

    Returns Promise<string>

    client ID

  • is_expired(): boolean
  • Checks if spotify token is expired or not.

    Update token if returned false.

    if (play.is_expired()) {
    await play.refreshToken()
    }

    Returns boolean

    boolean

  • Gets YouTube playlist info from a playlist url.

    Example

    const playlist = await play.playlist_info('youtube playlist url')

    const playlist = await play.playlist_info('youtube playlist url', { incomplete : true })

    Parameters

    • url: string

      Playlist URL

    • options: PlaylistOptions = {}

      Playlist Info Options

      • boolean incomplete : When this is set to false (default) this function will throw an error if the playlist contains hidden videos. If it is set to true, it parses the playlist skipping the hidden videos, only visible videos are included in the resulting {@link YouTubePlaylist}.

    Returns Promise<YouTubePlayList>

    YouTube Playlist

  • refreshToken(): Promise<boolean>
  • Refreshes Token

    if (play.is_expired()) {
    await play.refreshToken()
    }

    Returns Promise<boolean>

    boolean

  • Searches through a particular source and gives respective info.

    Example

    const searched = await play.search('Rick Roll', { source : { youtube : "video" } }) // YouTube Video Search

    const searched = await play.search('Rick Roll', { limit : 1 }) // YouTube Video Search but returns only 1 video.

    const searched = await play.search('Rick Roll', { source : { spotify : "track" } }) // Spotify Track Search

    const searched = await play.search('Rick Roll', { source : { soundcloud : "tracks" } }) // SoundCloud Track Search

    const searched = await play.search('Rick Roll', { source : { deezer : "track" } }) // Deezer Track Search

    Parameters

    • query: string

      string to search.

    • options: { source: { deezer: "album" } } & SearchOptions
      • number limit : No of searches you want to have.
      • string language : Sets language of searched content [ YouTube search only. ], e.g. "en-US"
      • boolean unblurNSFWThumbnails : Unblurs NSFW thumbnails. Defaults to false [ YouTube search only. ] !!! Before enabling this for public servers, please consider using Discord features like NSFW channels as not everyone in your server wants to see NSFW images. !!! Unblurred images will likely have different dimensions than specified in the YouTubeThumbnail objects.
      • boolean fuzzy : Whether the search should be fuzzy or only return exact matches. Defaults to true. [ for Deezer Only ]
      • Object source : Contains type of source and type of result you want to have ```ts
        • youtube : 'video' | 'playlist' | 'channel';
      • spotify : 'album' | 'playlist' | 'track';
      • soundcloud : 'tracks' | 'playlists' | 'albums';
      • deezer : 'track' | 'playlist' | 'album'; ```

    Returns Promise<DeezerAlbum[]>

    Array of YouTube or Spotify or SoundCloud or Deezer type

  • Searches through a particular source and gives respective info.

    Example

    const searched = await play.search('Rick Roll', { source : { youtube : "video" } }) // YouTube Video Search

    const searched = await play.search('Rick Roll', { limit : 1 }) // YouTube Video Search but returns only 1 video.

    const searched = await play.search('Rick Roll', { source : { spotify : "track" } }) // Spotify Track Search

    const searched = await play.search('Rick Roll', { source : { soundcloud : "tracks" } }) // SoundCloud Track Search

    const searched = await play.search('Rick Roll', { source : { deezer : "track" } }) // Deezer Track Search

    Parameters

    • query: string

      string to search.

    • options: { source: { deezer: "playlist" } } & SearchOptions
      • number limit : No of searches you want to have.
      • string language : Sets language of searched content [ YouTube search only. ], e.g. "en-US"
      • boolean unblurNSFWThumbnails : Unblurs NSFW thumbnails. Defaults to false [ YouTube search only. ] !!! Before enabling this for public servers, please consider using Discord features like NSFW channels as not everyone in your server wants to see NSFW images. !!! Unblurred images will likely have different dimensions than specified in the YouTubeThumbnail objects.
      • boolean fuzzy : Whether the search should be fuzzy or only return exact matches. Defaults to true. [ for Deezer Only ]
      • Object source : Contains type of source and type of result you want to have ```ts
        • youtube : 'video' | 'playlist' | 'channel';
      • spotify : 'album' | 'playlist' | 'track';
      • soundcloud : 'tracks' | 'playlists' | 'albums';
      • deezer : 'track' | 'playlist' | 'album'; ```

    Returns Promise<DeezerPlaylist[]>

    Array of YouTube or Spotify or SoundCloud or Deezer type

  • Searches through a particular source and gives respective info.

    Example

    const searched = await play.search('Rick Roll', { source : { youtube : "video" } }) // YouTube Video Search

    const searched = await play.search('Rick Roll', { limit : 1 }) // YouTube Video Search but returns only 1 video.

    const searched = await play.search('Rick Roll', { source : { spotify : "track" } }) // Spotify Track Search

    const searched = await play.search('Rick Roll', { source : { soundcloud : "tracks" } }) // SoundCloud Track Search

    const searched = await play.search('Rick Roll', { source : { deezer : "track" } }) // Deezer Track Search

    Parameters

    • query: string

      string to search.

    • options: { source: { deezer: "track" } } & SearchOptions
      • number limit : No of searches you want to have.
      • string language : Sets language of searched content [ YouTube search only. ], e.g. "en-US"
      • boolean unblurNSFWThumbnails : Unblurs NSFW thumbnails. Defaults to false [ YouTube search only. ] !!! Before enabling this for public servers, please consider using Discord features like NSFW channels as not everyone in your server wants to see NSFW images. !!! Unblurred images will likely have different dimensions than specified in the YouTubeThumbnail objects.
      • boolean fuzzy : Whether the search should be fuzzy or only return exact matches. Defaults to true. [ for Deezer Only ]
      • Object source : Contains type of source and type of result you want to have ```ts
        • youtube : 'video' | 'playlist' | 'channel';
      • spotify : 'album' | 'playlist' | 'track';
      • soundcloud : 'tracks' | 'playlists' | 'albums';
      • deezer : 'track' | 'playlist' | 'album'; ```

    Returns Promise<DeezerTrack[]>

    Array of YouTube or Spotify or SoundCloud or Deezer type

  • Searches through a particular source and gives respective info.

    Example

    const searched = await play.search('Rick Roll', { source : { youtube : "video" } }) // YouTube Video Search

    const searched = await play.search('Rick Roll', { limit : 1 }) // YouTube Video Search but returns only 1 video.

    const searched = await play.search('Rick Roll', { source : { spotify : "track" } }) // Spotify Track Search

    const searched = await play.search('Rick Roll', { source : { soundcloud : "tracks" } }) // SoundCloud Track Search

    const searched = await play.search('Rick Roll', { source : { deezer : "track" } }) // Deezer Track Search

    Parameters

    • query: string

      string to search.

    • options: { source: { soundcloud: "albums" } } & SearchOptions
      • number limit : No of searches you want to have.
      • string language : Sets language of searched content [ YouTube search only. ], e.g. "en-US"
      • boolean unblurNSFWThumbnails : Unblurs NSFW thumbnails. Defaults to false [ YouTube search only. ] !!! Before enabling this for public servers, please consider using Discord features like NSFW channels as not everyone in your server wants to see NSFW images. !!! Unblurred images will likely have different dimensions than specified in the YouTubeThumbnail objects.
      • boolean fuzzy : Whether the search should be fuzzy or only return exact matches. Defaults to true. [ for Deezer Only ]
      • Object source : Contains type of source and type of result you want to have ```ts
        • youtube : 'video' | 'playlist' | 'channel';
      • spotify : 'album' | 'playlist' | 'track';
      • soundcloud : 'tracks' | 'playlists' | 'albums';
      • deezer : 'track' | 'playlist' | 'album'; ```

    Returns Promise<SoundCloudPlaylist[]>

    Array of YouTube or Spotify or SoundCloud or Deezer type

  • Searches through a particular source and gives respective info.

    Example

    const searched = await play.search('Rick Roll', { source : { youtube : "video" } }) // YouTube Video Search

    const searched = await play.search('Rick Roll', { limit : 1 }) // YouTube Video Search but returns only 1 video.

    const searched = await play.search('Rick Roll', { source : { spotify : "track" } }) // Spotify Track Search

    const searched = await play.search('Rick Roll', { source : { soundcloud : "tracks" } }) // SoundCloud Track Search

    const searched = await play.search('Rick Roll', { source : { deezer : "track" } }) // Deezer Track Search

    Parameters

    • query: string

      string to search.

    • options: { source: { soundcloud: "playlists" } } & SearchOptions
      • number limit : No of searches you want to have.
      • string language : Sets language of searched content [ YouTube search only. ], e.g. "en-US"
      • boolean unblurNSFWThumbnails : Unblurs NSFW thumbnails. Defaults to false [ YouTube search only. ] !!! Before enabling this for public servers, please consider using Discord features like NSFW channels as not everyone in your server wants to see NSFW images. !!! Unblurred images will likely have different dimensions than specified in the YouTubeThumbnail objects.
      • boolean fuzzy : Whether the search should be fuzzy or only return exact matches. Defaults to true. [ for Deezer Only ]
      • Object source : Contains type of source and type of result you want to have ```ts
        • youtube : 'video' | 'playlist' | 'channel';
      • spotify : 'album' | 'playlist' | 'track';
      • soundcloud : 'tracks' | 'playlists' | 'albums';
      • deezer : 'track' | 'playlist' | 'album'; ```

    Returns Promise<SoundCloudPlaylist[]>

    Array of YouTube or Spotify or SoundCloud or Deezer type

  • Searches through a particular source and gives respective info.

    Example

    const searched = await play.search('Rick Roll', { source : { youtube : "video" } }) // YouTube Video Search

    const searched = await play.search('Rick Roll', { limit : 1 }) // YouTube Video Search but returns only 1 video.

    const searched = await play.search('Rick Roll', { source : { spotify : "track" } }) // Spotify Track Search

    const searched = await play.search('Rick Roll', { source : { soundcloud : "tracks" } }) // SoundCloud Track Search

    const searched = await play.search('Rick Roll', { source : { deezer : "track" } }) // Deezer Track Search

    Parameters

    • query: string

      string to search.

    • options: { source: { soundcloud: "tracks" } } & SearchOptions
      • number limit : No of searches you want to have.
      • string language : Sets language of searched content [ YouTube search only. ], e.g. "en-US"
      • boolean unblurNSFWThumbnails : Unblurs NSFW thumbnails. Defaults to false [ YouTube search only. ] !!! Before enabling this for public servers, please consider using Discord features like NSFW channels as not everyone in your server wants to see NSFW images. !!! Unblurred images will likely have different dimensions than specified in the YouTubeThumbnail objects.
      • boolean fuzzy : Whether the search should be fuzzy or only return exact matches. Defaults to true. [ for Deezer Only ]
      • Object source : Contains type of source and type of result you want to have ```ts
        • youtube : 'video' | 'playlist' | 'channel';
      • spotify : 'album' | 'playlist' | 'track';
      • soundcloud : 'tracks' | 'playlists' | 'albums';
      • deezer : 'track' | 'playlist' | 'album'; ```

    Returns Promise<SoundCloudTrack[]>

    Array of YouTube or Spotify or SoundCloud or Deezer type

  • Searches through a particular source and gives respective info.

    Example

    const searched = await play.search('Rick Roll', { source : { youtube : "video" } }) // YouTube Video Search

    const searched = await play.search('Rick Roll', { limit : 1 }) // YouTube Video Search but returns only 1 video.

    const searched = await play.search('Rick Roll', { source : { spotify : "track" } }) // Spotify Track Search

    const searched = await play.search('Rick Roll', { source : { soundcloud : "tracks" } }) // SoundCloud Track Search

    const searched = await play.search('Rick Roll', { source : { deezer : "track" } }) // Deezer Track Search

    Parameters

    • query: string

      string to search.

    • options: { source: { spotify: "album" } } & SearchOptions
      • number limit : No of searches you want to have.
      • string language : Sets language of searched content [ YouTube search only. ], e.g. "en-US"
      • boolean unblurNSFWThumbnails : Unblurs NSFW thumbnails. Defaults to false [ YouTube search only. ] !!! Before enabling this for public servers, please consider using Discord features like NSFW channels as not everyone in your server wants to see NSFW images. !!! Unblurred images will likely have different dimensions than specified in the YouTubeThumbnail objects.
      • boolean fuzzy : Whether the search should be fuzzy or only return exact matches. Defaults to true. [ for Deezer Only ]
      • Object source : Contains type of source and type of result you want to have ```ts
        • youtube : 'video' | 'playlist' | 'channel';
      • spotify : 'album' | 'playlist' | 'track';
      • soundcloud : 'tracks' | 'playlists' | 'albums';
      • deezer : 'track' | 'playlist' | 'album'; ```

    Returns Promise<SpotifyAlbum[]>

    Array of YouTube or Spotify or SoundCloud or Deezer type

  • Searches through a particular source and gives respective info.

    Example

    const searched = await play.search('Rick Roll', { source : { youtube : "video" } }) // YouTube Video Search

    const searched = await play.search('Rick Roll', { limit : 1 }) // YouTube Video Search but returns only 1 video.

    const searched = await play.search('Rick Roll', { source : { spotify : "track" } }) // Spotify Track Search

    const searched = await play.search('Rick Roll', { source : { soundcloud : "tracks" } }) // SoundCloud Track Search

    const searched = await play.search('Rick Roll', { source : { deezer : "track" } }) // Deezer Track Search

    Parameters

    • query: string

      string to search.

    • options: { source: { spotify: "playlist" } } & SearchOptions
      • number limit : No of searches you want to have.
      • string language : Sets language of searched content [ YouTube search only. ], e.g. "en-US"
      • boolean unblurNSFWThumbnails : Unblurs NSFW thumbnails. Defaults to false [ YouTube search only. ] !!! Before enabling this for public servers, please consider using Discord features like NSFW channels as not everyone in your server wants to see NSFW images. !!! Unblurred images will likely have different dimensions than specified in the YouTubeThumbnail objects.
      • boolean fuzzy : Whether the search should be fuzzy or only return exact matches. Defaults to true. [ for Deezer Only ]
      • Object source : Contains type of source and type of result you want to have ```ts
        • youtube : 'video' | 'playlist' | 'channel';
      • spotify : 'album' | 'playlist' | 'track';
      • soundcloud : 'tracks' | 'playlists' | 'albums';
      • deezer : 'track' | 'playlist' | 'album'; ```

    Returns Promise<SpotifyPlaylist[]>

    Array of YouTube or Spotify or SoundCloud or Deezer type

  • Searches through a particular source and gives respective info.

    Example

    const searched = await play.search('Rick Roll', { source : { youtube : "video" } }) // YouTube Video Search

    const searched = await play.search('Rick Roll', { limit : 1 }) // YouTube Video Search but returns only 1 video.

    const searched = await play.search('Rick Roll', { source : { spotify : "track" } }) // Spotify Track Search

    const searched = await play.search('Rick Roll', { source : { soundcloud : "tracks" } }) // SoundCloud Track Search

    const searched = await play.search('Rick Roll', { source : { deezer : "track" } }) // Deezer Track Search

    Parameters

    • query: string

      string to search.

    • options: { source: { spotify: "track" } } & SearchOptions
      • number limit : No of searches you want to have.
      • string language : Sets language of searched content [ YouTube search only. ], e.g. "en-US"
      • boolean unblurNSFWThumbnails : Unblurs NSFW thumbnails. Defaults to false [ YouTube search only. ] !!! Before enabling this for public servers, please consider using Discord features like NSFW channels as not everyone in your server wants to see NSFW images. !!! Unblurred images will likely have different dimensions than specified in the YouTubeThumbnail objects.
      • boolean fuzzy : Whether the search should be fuzzy or only return exact matches. Defaults to true. [ for Deezer Only ]
      • Object source : Contains type of source and type of result you want to have ```ts
        • youtube : 'video' | 'playlist' | 'channel';
      • spotify : 'album' | 'playlist' | 'track';
      • soundcloud : 'tracks' | 'playlists' | 'albums';
      • deezer : 'track' | 'playlist' | 'album'; ```

    Returns Promise<SpotifyTrack[]>

    Array of YouTube or Spotify or SoundCloud or Deezer type

  • Searches through a particular source and gives respective info.

    Example

    const searched = await play.search('Rick Roll', { source : { youtube : "video" } }) // YouTube Video Search

    const searched = await play.search('Rick Roll', { limit : 1 }) // YouTube Video Search but returns only 1 video.

    const searched = await play.search('Rick Roll', { source : { spotify : "track" } }) // Spotify Track Search

    const searched = await play.search('Rick Roll', { source : { soundcloud : "tracks" } }) // SoundCloud Track Search

    const searched = await play.search('Rick Roll', { source : { deezer : "track" } }) // Deezer Track Search

    Parameters

    • query: string

      string to search.

    • options: { source: { youtube: "channel" } } & SearchOptions
      • number limit : No of searches you want to have.
      • string language : Sets language of searched content [ YouTube search only. ], e.g. "en-US"
      • boolean unblurNSFWThumbnails : Unblurs NSFW thumbnails. Defaults to false [ YouTube search only. ] !!! Before enabling this for public servers, please consider using Discord features like NSFW channels as not everyone in your server wants to see NSFW images. !!! Unblurred images will likely have different dimensions than specified in the YouTubeThumbnail objects.
      • boolean fuzzy : Whether the search should be fuzzy or only return exact matches. Defaults to true. [ for Deezer Only ]
      • Object source : Contains type of source and type of result you want to have ```ts
        • youtube : 'video' | 'playlist' | 'channel';
      • spotify : 'album' | 'playlist' | 'track';
      • soundcloud : 'tracks' | 'playlists' | 'albums';
      • deezer : 'track' | 'playlist' | 'album'; ```

    Returns Promise<YouTubeChannel[]>

    Array of YouTube or Spotify or SoundCloud or Deezer type

  • Searches through a particular source and gives respective info.

    Example

    const searched = await play.search('Rick Roll', { source : { youtube : "video" } }) // YouTube Video Search

    const searched = await play.search('Rick Roll', { limit : 1 }) // YouTube Video Search but returns only 1 video.

    const searched = await play.search('Rick Roll', { source : { spotify : "track" } }) // Spotify Track Search

    const searched = await play.search('Rick Roll', { source : { soundcloud : "tracks" } }) // SoundCloud Track Search

    const searched = await play.search('Rick Roll', { source : { deezer : "track" } }) // Deezer Track Search

    Parameters

    • query: string

      string to search.

    • options: { source: { youtube: "playlist" } } & SearchOptions
      • number limit : No of searches you want to have.
      • string language : Sets language of searched content [ YouTube search only. ], e.g. "en-US"
      • boolean unblurNSFWThumbnails : Unblurs NSFW thumbnails. Defaults to false [ YouTube search only. ] !!! Before enabling this for public servers, please consider using Discord features like NSFW channels as not everyone in your server wants to see NSFW images. !!! Unblurred images will likely have different dimensions than specified in the YouTubeThumbnail objects.
      • boolean fuzzy : Whether the search should be fuzzy or only return exact matches. Defaults to true. [ for Deezer Only ]
      • Object source : Contains type of source and type of result you want to have ```ts
        • youtube : 'video' | 'playlist' | 'channel';
      • spotify : 'album' | 'playlist' | 'track';
      • soundcloud : 'tracks' | 'playlists' | 'albums';
      • deezer : 'track' | 'playlist' | 'album'; ```

    Returns Promise<YouTubePlayList[]>

    Array of YouTube or Spotify or SoundCloud or Deezer type

  • Searches through a particular source and gives respective info.

    Example

    const searched = await play.search('Rick Roll', { source : { youtube : "video" } }) // YouTube Video Search

    const searched = await play.search('Rick Roll', { limit : 1 }) // YouTube Video Search but returns only 1 video.

    const searched = await play.search('Rick Roll', { source : { spotify : "track" } }) // Spotify Track Search

    const searched = await play.search('Rick Roll', { source : { soundcloud : "tracks" } }) // SoundCloud Track Search

    const searched = await play.search('Rick Roll', { source : { deezer : "track" } }) // Deezer Track Search

    Parameters

    • query: string

      string to search.

    • options: { source: { youtube: "video" } } & SearchOptions
      • number limit : No of searches you want to have.
      • string language : Sets language of searched content [ YouTube search only. ], e.g. "en-US"
      • boolean unblurNSFWThumbnails : Unblurs NSFW thumbnails. Defaults to false [ YouTube search only. ] !!! Before enabling this for public servers, please consider using Discord features like NSFW channels as not everyone in your server wants to see NSFW images. !!! Unblurred images will likely have different dimensions than specified in the YouTubeThumbnail objects.
      • boolean fuzzy : Whether the search should be fuzzy or only return exact matches. Defaults to true. [ for Deezer Only ]
      • Object source : Contains type of source and type of result you want to have ```ts
        • youtube : 'video' | 'playlist' | 'channel';
      • spotify : 'album' | 'playlist' | 'track';
      • soundcloud : 'tracks' | 'playlists' | 'albums';
      • deezer : 'track' | 'playlist' | 'album'; ```

    Returns Promise<YouTubeVideo[]>

    Array of YouTube or Spotify or SoundCloud or Deezer type

  • Searches through a particular source and gives respective info.

    Example

    const searched = await play.search('Rick Roll', { source : { youtube : "video" } }) // YouTube Video Search

    const searched = await play.search('Rick Roll', { limit : 1 }) // YouTube Video Search but returns only 1 video.

    const searched = await play.search('Rick Roll', { source : { spotify : "track" } }) // Spotify Track Search

    const searched = await play.search('Rick Roll', { source : { soundcloud : "tracks" } }) // SoundCloud Track Search

    const searched = await play.search('Rick Roll', { source : { deezer : "track" } }) // Deezer Track Search

    Parameters

    • query: string

      string to search.

    • options: { limit: number } & SearchOptions
      • number limit : No of searches you want to have.
      • string language : Sets language of searched content [ YouTube search only. ], e.g. "en-US"
      • boolean unblurNSFWThumbnails : Unblurs NSFW thumbnails. Defaults to false [ YouTube search only. ] !!! Before enabling this for public servers, please consider using Discord features like NSFW channels as not everyone in your server wants to see NSFW images. !!! Unblurred images will likely have different dimensions than specified in the YouTubeThumbnail objects.
      • boolean fuzzy : Whether the search should be fuzzy or only return exact matches. Defaults to true. [ for Deezer Only ]
      • Object source : Contains type of source and type of result you want to have ```ts
        • youtube : 'video' | 'playlist' | 'channel';
      • spotify : 'album' | 'playlist' | 'track';
      • soundcloud : 'tracks' | 'playlists' | 'albums';
      • deezer : 'track' | 'playlist' | 'album'; ```

    Returns Promise<YouTubeVideo[]>

    Array of YouTube or Spotify or SoundCloud or Deezer type

  • Searches through a particular source and gives respective info.

    Example

    const searched = await play.search('Rick Roll', { source : { youtube : "video" } }) // YouTube Video Search

    const searched = await play.search('Rick Roll', { limit : 1 }) // YouTube Video Search but returns only 1 video.

    const searched = await play.search('Rick Roll', { source : { spotify : "track" } }) // Spotify Track Search

    const searched = await play.search('Rick Roll', { source : { soundcloud : "tracks" } }) // SoundCloud Track Search

    const searched = await play.search('Rick Roll', { source : { deezer : "track" } }) // Deezer Track Search

    Parameters

    • query: string

      string to search.

    • Optional options: SearchOptions
      • number limit : No of searches you want to have.
      • string language : Sets language of searched content [ YouTube search only. ], e.g. "en-US"
      • boolean unblurNSFWThumbnails : Unblurs NSFW thumbnails. Defaults to false [ YouTube search only. ] !!! Before enabling this for public servers, please consider using Discord features like NSFW channels as not everyone in your server wants to see NSFW images. !!! Unblurred images will likely have different dimensions than specified in the YouTubeThumbnail objects.
      • boolean fuzzy : Whether the search should be fuzzy or only return exact matches. Defaults to true. [ for Deezer Only ]
      • Object source : Contains type of source and type of result you want to have ```ts
        • youtube : 'video' | 'playlist' | 'channel';
      • spotify : 'album' | 'playlist' | 'track';
      • soundcloud : 'tracks' | 'playlists' | 'albums';
      • deezer : 'track' | 'playlist' | 'album'; ```

    Returns Promise<YouTubeVideo[]>

    Array of YouTube or Spotify or SoundCloud or Deezer type

  • Sets

    i> YouTube :- cookies.

    ii> SoundCloud :- client ID.

    iii> Spotify :- client ID, client secret, refresh token, market.

    iv> Useragents :- array of string.

    locally in memory.

    Example :

    play.setToken({
    youtube : {
    cookie : "Your Cookies"
    }
    }) // YouTube Cookies

    await play.setToken({
    spotify : {
    client_id: 'ID',
    client_secret: 'secret',
    refresh_token: 'token',
    market: 'US'
    }
    }) // Await this only when setting data for spotify

    play.setToken({
    useragent: ['Your User-agent']
    }) // Use this to avoid 429 errors.

    Parameters

    Returns Promise<void>

  • so_validate(url: string): Promise<false | "track" | "playlist" | "search">
  • Validates a soundcloud url

    Parameters

    • url: string

      soundcloud url

    Returns Promise<false | "track" | "playlist" | "search">

    false | 'track' | 'playlist'
    
  • Gets info from a soundcloud url.

    let sound = await play.soundcloud('soundcloud url')

    // sound.type === "track" | "playlist" | "user"

    if (sound.type === "track") {
    spot = spot as play.SoundCloudTrack
    // Code with SoundCloud track class.
    }

    Parameters

    • url: string

      soundcloud url

    Returns Promise<SoundCloud>

  • sp_validate(url: string): "track" | "playlist" | "album" | "search" | false
  • Validate Spotify url

    Parameters

    • url: string

      Spotify URL

    Returns "track" | "playlist" | "album" | "search" | false

    'track' | 'playlist' | 'album' | 'search' | false
    
  • spotify(url: string): Promise<Spotify>
  • Gets Spotify url details.

    let spot = await play.spotify('spotify url')

    // spot.type === "track" | "playlist" | "album"

    if (spot.type === "track") {
    spot = spot as play.SpotifyTrack
    // Code with spotify track class.
    }

    Parameters

    • url: string

      Spotify Url

    Returns Promise<Spotify>

  • Creates a Stream [ YouTube or SoundCloud ] class from a url for playing.

    Example

    const source = await play.stream('youtube video URL') // YouTube Video Stream

    const source = await play.stream('soundcloud track URL') // SoundCloud Track Stream

    const source = await play.stream('youtube video URL', { seek : 45 }) // Seeks 45 seconds (approx.) in YouTube Video Stream

    const resource = createAudioResource(source.stream, {
    inputType : source.type
    }) // Use discordjs voice createAudioResource function.

    Parameters

    • url: string

      Video / Track URL

    • options: { seek?: number } & StreamOptions
      • number seek : No of seconds to seek in stream.
      • string language : Sets language of searched content [ YouTube search only. ], e.g. "en-US"
      • number quality : Quality number. [ 0 = Lowest, 1 = Medium, 2 = Highest ]
      • boolean htmldata : given data is html data or not
      • number precache : No of segments of data to store before looping [YouTube Live Stream only]. [ Defaults to 3 ]
      • boolean discordPlayerCompatibility : Conversion of Webm to Opus [ Defaults to false ]

    Returns Promise<YouTubeStream>

    A YouTubeStream or SoundCloudStream Stream to play

  • Creates a Stream [ YouTube or SoundCloud ] class from a url for playing.

    Example

    const source = await play.stream('youtube video URL') // YouTube Video Stream

    const source = await play.stream('soundcloud track URL') // SoundCloud Track Stream

    const source = await play.stream('youtube video URL', { seek : 45 }) // Seeks 45 seconds (approx.) in YouTube Video Stream

    const resource = createAudioResource(source.stream, {
    inputType : source.type
    }) // Use discordjs voice createAudioResource function.

    Parameters

    • url: string

      Video / Track URL

    • Optional options: StreamOptions
      • number seek : No of seconds to seek in stream.
      • string language : Sets language of searched content [ YouTube search only. ], e.g. "en-US"
      • number quality : Quality number. [ 0 = Lowest, 1 = Medium, 2 = Highest ]
      • boolean htmldata : given data is html data or not
      • number precache : No of segments of data to store before looping [YouTube Live Stream only]. [ Defaults to 3 ]
      • boolean discordPlayerCompatibility : Conversion of Webm to Opus [ Defaults to false ]

    Returns Promise<YouTubeStream | SoundCloudStream>

    A YouTubeStream or SoundCloudStream Stream to play

  • Creates a Stream [ YouTube or SoundCloud ] class from video or track info for playing.

    Example

    const info = await video_info('youtube URL')
    const source = await play.stream_from_info(info) // YouTube Video Stream

    const soundInfo = await play.soundcloud('SoundCloud URL')
    const source = await play.stream_from_info(soundInfo) // SoundCloud Track Stream

    const source = await play.stream_from_info(info, { seek : 45 }) // Seeks 45 seconds (approx.) in YouTube Video Stream

    const resource = createAudioResource(source.stream, {
    inputType : source.type
    }) // Use discordjs voice createAudioResource function.

    Parameters

    • info: SoundCloudTrack

      YouTube video info OR SoundCloud track Class

    • Optional options: StreamOptions
      • number seek : No of seconds to seek in stream.
      • string language : Sets language of searched content [ YouTube search only. ], e.g. "en-US"
      • number quality : Quality number. [ 0 = Lowest, 1 = Medium, 2 = Highest ]
      • boolean htmldata : given data is html data or not
      • number precache : No of segments of data to store before looping [YouTube Live Stream only]. [ Defaults to 3 ]
      • boolean discordPlayerCompatibility : Conversion of Webm to Opus[ Defaults to false ]

    Returns Promise<SoundCloudStream>

    A YouTubeStream or SoundCloudStream Stream to play

  • Creates a Stream [ YouTube or SoundCloud ] class from video or track info for playing.

    Example

    const info = await video_info('youtube URL')
    const source = await play.stream_from_info(info) // YouTube Video Stream

    const soundInfo = await play.soundcloud('SoundCloud URL')
    const source = await play.stream_from_info(soundInfo) // SoundCloud Track Stream

    const source = await play.stream_from_info(info, { seek : 45 }) // Seeks 45 seconds (approx.) in YouTube Video Stream

    const resource = createAudioResource(source.stream, {
    inputType : source.type
    }) // Use discordjs voice createAudioResource function.

    Parameters

    • info: InfoData

      YouTube video info OR SoundCloud track Class

    • Optional options: StreamOptions
      • number seek : No of seconds to seek in stream.
      • string language : Sets language of searched content [ YouTube search only. ], e.g. "en-US"
      • number quality : Quality number. [ 0 = Lowest, 1 = Medium, 2 = Highest ]
      • boolean htmldata : given data is html data or not
      • number precache : No of segments of data to store before looping [YouTube Live Stream only]. [ Defaults to 3 ]
      • boolean discordPlayerCompatibility : Conversion of Webm to Opus[ Defaults to false ]

    Returns Promise<YouTubeStream>

    A YouTubeStream or SoundCloudStream Stream to play

  • validate(url: string): Promise<"so_playlist" | "so_track" | "sp_track" | "sp_album" | "sp_playlist" | "dz_track" | "dz_playlist" | "dz_album" | "yt_video" | "yt_playlist" | "search" | false>
  • Validates url that play-dl supports.

    • so - SoundCloud
    • sp - Spotify
    • dz - Deezer
    • yt - YouTube

    Parameters

    • url: string

      URL

    Returns Promise<"so_playlist" | "so_track" | "sp_track" | "sp_album" | "sp_playlist" | "dz_track" | "dz_playlist" | "dz_album" | "yt_video" | "yt_playlist" | "search" | false>

    'so_playlist' / 'so_track' | 'sp_track' | 'sp_album' | 'sp_playlist' | 'dz_track' | 'dz_playlist' | 'dz_album' | 'yt_video' | 'yt_playlist' | 'search' | false
    
  • Basic function to get data from a YouTube url or ID.

    Example

    const video = await play.video_basic_info('youtube video url')

    const res = ... // Any https package get function.

    const video = await play.video_basic_info(res.body, { htmldata : true })

    Parameters

    • url: string

      YouTube url or ID or html body data

    • options: InfoOptions = {}

      Video Info Options

      • boolean htmldata : given data is html data or not

    Returns Promise<InfoData>

    Video Basic Info InfoData.

  • Gets data from YouTube url or ID or html body data and deciphers it.

    video_basic_info + decipher_info = video_info
    

    Example

    const video = await play.video_info('youtube video url')

    const res = ... // Any https package get function.

    const video = await play.video_info(res.body, { htmldata : true })

    Parameters

    • url: string

      YouTube url or ID or html body data

    • options: InfoOptions = {}

      Video Info Options

      • boolean htmldata : given data is html data or not

    Returns Promise<InfoData>

    Deciphered Video Info InfoData.

  • yt_validate(url: string): "playlist" | "video" | "search" | false
  • Validate YouTube URL or ID.

    CAUTION : If your search word is 11 or 12 characters long, you might get it validated as video ID.

    To avoid above, add one more condition to yt_validate

    if (url.startsWith('https') && yt_validate(url) === 'video') {
    // YouTube Video Url.
    }

    Parameters

    • url: string

      YouTube URL OR ID

    Returns "playlist" | "video" | "search" | false

    'playlist' | 'video' | 'search' | false
    

Generated using TypeDoc