2021-10-18 17:11:48 +05:30

2.2 KiB

SoundCloud

Main

soundcloud(url : string)

This returns data from a track | playlist url.

let data = await soundcloud(url) //Gets the data

console.log(data.type) // Console logs the type of data that you got.

getFreeClientID()

This returns free client ID.

const client_id = await getFreeClientID()

setToken({
    soundcloud : {
        client_id : client_id
    }
}) // This will set client ID for use in play-dl.

Validate

so_validate(url : string)

This checks that given url is soundcloud url or not.

Returns : track | playlist | search | false

let check = await so_validate(url)

if(!check) // Invalid SoundCloud URL

if(check === 'track') // SoundCloud Track URL

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

Classes [ Returned by soundcloud(url) function ]

SoundCloudTrack

This is class for a soundcloud track.

type property

This will always return as "track" for this class.

toJSON() function

converts class into a json format

SoundCloudPlaylist

This is a soundcloud playlist class.

fetch() function

This will fetch tracks in a playlist.

let data = await soundcloud(playlist_url)

await data.fetch() // Fetches all unfetched tracks in playlist
tracksCount property

This will give no. of tracks in a playlist.

let data = await soundcloud(playlist_url)

console.log(data.tracksCount) // Returns total tracks count in a playlist

tracks property

This will give all tracks fetched as array.

let data = await soundcloud(playlist_url)

console.log(data.tracks) // Tracks Array

data.tracks.forEach((track) => {
    queue.push(track) // This will push every track in playlist to your queue
})

total_tracks property

This give total videos that have been fetched so far.

let data = await soundcloud(playlist_url)

console.log(data.total_tracks) // This will tell no. of videos that have been fetched so far.
type property

This will always return as "playlist" for this class.

toJSON() function

converts class into a json format