play-dl-fix/docs/README.md
Killer069 4c8162ecdd
1.2.6
Added option to pass html body data directly to video_basic_info | video_info | stream functions.
 Fixed Playlist ID regexp to allow multiple playlist ID support.
 Added Dezer advanced search
 Improved Deezer Share Link handling.
 Added cookiesHeaders options to update cookies when using external https request module.
 Added Artists badge in YouTubeChannel Class.
2021-11-01 15:43:52 +05:30

5.8 KiB

Play-dl commands

For source specific commands :-

Validate

validate(url : string)

This checks all type of urls that are supported by play-dl.

Returns : so_playlist | so_track | sp_track | sp_album | sp_playlist | dz_track | dz_playlist | dz_album | yt_video | yt_playlist | search | false

so = SoundCloud

sp = Spotify

yt = YouTube

dz = Deezer

let check = await validate(url)

if(!check) // Invalid URL

if(check === 'yt_video') // YouTube Video

if(check === 'sp_track') // Spotify Track

if(check === 'so_track') // SoundCloud Track

if(check === 'dz_track') // Deezer Track

if(check === "search") // Given term is not a url. Search this term somewhere.

authorization()

This creates basic spotify / soundcloud / youtube data to be stored locally.

authorization() //After then you will be asked about type of data you want to create and then follow the steps properly.

setToken(options : TokenOptions)

This sets token without using file.

setToken({
    spotify : {
        client_id : "ID",
        client_secret : "Secret",
        refresh_token : "Token",
        market : "Country Code"
    }
}) // Setting Spotify Token [ To get refresh_token, just run through authorization, and set file save to No ]

setToken({
    soundcloud : {
        client_id : "ID"
    }
}) // Setting SoundCloud Token

setToken({
    youtube : {
        cookie : "Cookies"
    }
}) // Warning : Using setToken for youtube cookies will only update cookies present in memory only.

SearchOptions :

  • limit : number :- Sets total amount of results you want.

  • source : {

    youtube: video | playlist | channel ;

    spotify: album | playlist | track ;

    soundcloud: tracks | playlists | albums ;

    deezer: track | playlist | album ;

    }

search(query : string, options? : SearchOptions)

This is basic to search with any source.

NOTE :- If options.source is not specified, then it will default to youtube video search.

let data = await search('Rick Roll', { limit : 1 }) // Searches for youtube video

let data = await search('Rick Roll', { limit : 1, source : { youtube : "video" } }) // Searches for youtube video

let data = await search('Rick Roll', { limit: 1, source : { spotify : "track" } }) // Searches for spotify track.

let data = await search('Rick Roll', { limit: 1, source : { soundcloud : "tracks" } }) // Searches for soundcloud track.

let data = await search('Rick Roll', { limit: 1, source : { deezer : "track" } }) // Searches for a Deezer track.

Stream

Attaching events to player is important for stream to work.

attachListeners(player : AudioPlayer, resource : YouTubeStream | SoundCloudStream)

This is used for attaching pause and playing events to audioPlayer.

let resource = await stream("url")

let player = createAudioPlayer()

attachListeners(player, resource)

StreamOptions :

  • quality : number :- Sets quality of stream [ 0 = Lowest, 1 = Medium ]. Leave this empty to get highest audio quality.
  • proxy : Proxy :- Optional parameter to add support of proxies. As of now, HTTPS proxies are only supported. So make sure to get HTTPS proxies only.

stream(url : string, options? : StreamOptions)

This is basic to create a stream from a youtube or soundcloud url.

let source = await stream("url") // This will create a stream Class. Highest Quality

let source = await stream("url", { quality : 0 }) // Lowest quality

let source = await stream("url", { quality : 1 }) // Next to Lowest quality.

let source = await stream(url, { proxy : ['url'] }) // Accepts a url which has port in it.

let source = await stream(url. {proxy : [{
        host : "IP or hostname",
        port : 8080
    }]
}) // Or add a json containing hostname and port.

let resource = createAudioResource(source.stream, {
            inputType : source.type
        }) // This creates resource for playing

stream_from_info(info : infoData, options? : StreamOptions)

This is basic to create a stream from a info [ from video_info function or soundcloud function [Only SoundCloudTrack class is allowed] ].

Note : Here, cookies are required only for retrying purposes.

let source = await stream_from_info(info) // This will create a stream Class from video_info or SoundCoudTrack Class. Highest Quality

let source = await stream_from_info(info, { quality : 0 }) // Lowest quality

let source = await stream_from_info(info, { quality : 1 }) // Next to Lowest quality.

let source = await stream_from_info(info, { proxy : ['url'] }) // Accepts a url which has port in it.

let source = await stream_from_info(info, {proxy : [{
        host : "IP or hostname",
        port : 8080
    }]
}) // Or add a json containing hostname and port.

let resource = createAudioResource(source.stream, {
            inputType : source.type
        }) // This creates resource for playing

cookieHeaders(headersCookie : string[])

This is function to update youtube cookies when using external https module.

const res = ... // You need to get response.

play.cookieHeaders(res.headers['set-cookie']) // Updates YouTube Cookies if cookies exists.