docs update

This commit is contained in:
killer069 2021-11-17 12:40:22 +05:30
parent 8ba5726f12
commit 4285f1a733
177 changed files with 76 additions and 964 deletions

View File

@ -1,181 +0,0 @@
# Deezer
## Main
### deezer(url : `string`)
_This returns data from a track | playlist | album url. Accepts share links as well, which it resolves first._
```js
let data = await deezer(url); //Gets the data
console.log(data.type); // Console logs the type of data that you got.
```
## Validate
### dz_validate(url : `string`)
_This checks that given url is Deezer url or not._
**Returns :** `track` | `album` | `playlist` | `search` | `false`
```js
let check = dz_validate(url)
if(!check) // Invalid Deezer URL
if(check === 'track') // Deezer Track URL
if(check === "search") // Given term is a search query. Search it somewhere.
```
## Search
### dz_search(query: `string`, options: `DeezerSearchOptions`)
_Searches for tracks, playlists and albums._
**Returns :** `Deezer[]` an array of tracks, playlists or albums
#### `DeezerSearchOptions`
- **type?** `'track'` | `'playlist'` | `'album'` The type to search for. Defaults to `'track'`.
- **limit?** `number` The maximum number of results to return. Maximum `100`, defaults to `10`.
- **fuzzy?** `boolean` Whether the search should be fuzzy or only return exact matches. Defaults to `true`.
```js
const results = await dz_search(query, {
limit: 1,
type: 'track',
fuzzy: false
}); // Returns an array with one track, using exact matching
```
### dz_advanced_track_search(options: `DeezerAdvancedSearchOptions`)
_Searches Deezer for tracks using the specified metadata._
**Returns :** `DeezerTrack[]` an array of tracks
#### `DeezerAdvancedSearchOptions`
- **limit?** `number` The maximum number of results to return, maximum `100`, defaults to `10`.
- **artist?** `string` The name of the artist
- **album?** `string` The title of the album
- **title?** `string` The title of the track
- **label?** `string` The label that released the track
- **minDurationInSec?** `number` The minimum duration in seconds
- **maxDurationInSec?** `number` The maximum duration in seconds
- **minBpm?** `number` The minimum BPM
- **maxBpm?** `number` The minimum BPM
```js
const results = await dz_advanced_track_search({
limit: 1,
artist: 'Rick Astley',
title: 'Never Gonna Give You Up'
}); // Returns an array with one track
```
## Classes [ Returned by `deezer(url)` function ]
### DeezerTrack
_This is the class for a Deezer track._
##### type `property`
_This will always return as "track" for this class._
##### partial `property`
_Will return true for tracks in search results and false for tracks fetched directly or if the fetch function has been called. This being true means that the optional properties are undefined._
##### toJSON() `function`
_Converts the object to JSON_
##### fetch() `function`
_Fetches the missing data for a partial track._
```js
const track = await deezer(track_url);
await track.fetch() // Fetches the missing data
```
### DeezerPlaylist
_This is the class for a Deezer playlist._
##### fetch() `function`
_This will fetch up to 1000 tracks in a playlist as well as the missing data for a partial playlist._
```js
let data = await deezer(playlist_url)
await data.fetch() // Fetches tracks more than 100 tracks in playlist
```
##### tracksCount `property`
_This will return the total number of tracks in a playlist._
```js
const data = await deezer(playlist_url)
console.log(data.tracksCount) // Total number of tracks in the playlist.
```
##### type `property`
_This will always return as "playlist" for this class._
##### partial `property`
_Will return true for playlists in search results and false for playlists fetched directly or if the fetch function has been called. This being true means that the optional properties are undefined and `tracks` may be empty or partially filled._
##### tracks `property`
_The array of tracks in this album, this is always empty (length of 0) for partial playlists._
```js
const data = await deezer(playlist_url);
if (data.tracks.length !== data.tracksCount) {
await data.fetch();
}
console.log(data.tracks); // returns all tracks in the playlist
```
##### toJSON() `function`
_Converts the object to JSON_
### DeezerAlbum
_This is the class for a Deezer album._
##### type `property`
_This will always return as "track" for this class._
##### tracks `property`
_The array of tracks in this album, this is always empty (length of 0) for partial albums._
##### partial `property`
_Will return true for albums in search results and false for albums fetched directly or if the fetch function has been called. This being true means that the optional properties are undefined._
##### toJSON() `function`
_Converts the object to JSON_
##### fetch() `function`
_Fetches the missing data for a partial album._

View File

@ -1,190 +0,0 @@
# Play-dl commands
For source specific commands :-
- [YouTube](https://github.com/play-dl/play-dl/tree/main/docs/YouTube#youtube)
- [Spotify](https://github.com/play-dl/play-dl/tree/main/docs/Spotify#spotify)
- [SoundCloud](https://github.com/play-dl/play-dl/tree/main/docs/SoundCloud)
### 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**
```js
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._
```js
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._
```js
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.
```
### Search
#### 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`](https://github.com/play-dl/play-dl/tree/main/docs#searchoptions-))
_This is basic to search with any source._
**NOTE :-** If options.source is not specified, then it will default to youtube video search.
```js
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._
```js
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`](https://github.com/play-dl/play-dl/tree/main/docs#streamoptions-))
_This is basic to create a stream from a youtube or soundcloud url._
```js
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`](https://github.com/play-dl/play-dl/tree/main/docs#streamoptions-))
_This is basic to create a stream from a info [ from [video_info](https://github.com/play-dl/play-dl#video_infourl--string) function or [soundcloud](https://github.com/play-dl/play-dl/tree/main/docs/SoundCloud#soundcloudurl--string) function [**Only SoundCloudTrack class is allowed**] ]._
**Note :** Here, cookies are required only for retrying purposes.
```js
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._
```js
const res = ... // You need to get response.
play.cookieHeaders(res.headers['set-cookie']) // Updates YouTube Cookies if cookies exists.
```

View File

@ -1,115 +0,0 @@
# SoundCloud
## Main
### soundcloud(url : `string`)
_This returns data from a track | playlist url._
```js
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._
```js
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`
```js
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._
```js
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._
```js
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._
```js
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._
```js
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_

View File

@ -1,204 +0,0 @@
# Spotify
## Main
### spotify(url : `string`)
_This returns data from a track | playlist | album url._
```js
let data = await spotify(url) //Gets the data
console.log(data.type) // Console logs the type of data that you got.
```
## Validate
### sp_validate(url : `string`)
_This checks that given url is spotify url or not._
**Returns :** `track` | `album` | `playlist` | `search` | `false`
```js
let check = sp_validate(url)
if(!check) // Invalid Spotify URL
if(check === 'track') // Spotify Track URL
if(check === "search") // Given term is a spotify url. Search it somewhere.
```
### is_expired()
_This tells that whether the access token is expired or not_
**Returns :** `boolean`
```js
if(is_expired()){
await refreshToken()
}
```
### refreshToken()
_This refreshes the access token._
**Returns :** `boolean` for telling whether access token is refreshed or not
```js
await refreshToken()
```
## Classes [ Returned by `spotify(url)` function ]
### SpotifyVideo
_Don't go by the name. This is class for a spotify track._
##### type `property`
_This will always return as "track" for this class._
##### toJSON() `function`
_converts class into a json format_
### SpotifyPlaylist
_This is a spotify playlist class._
##### fetch() `function`
_This will fetch tracks in a playlist upto 1000 tracks only._
```js
let data = await spotify(playlist_url)
await data.fetch() // Fetches tracks more than 100 tracks in playlist
```
##### tracksCount `property`
_This will give no. of tracks in a playlist._
```js
let data = await spotify(playlist_url)
console.log(data.tracksCount) // Returns total tracks count in a playlist
```
##### page(page_number : `number`)
_This will return array of tracks in that page._
> Same as youtube playlist pages
```js
let data = await spotify(playlist_url)
console.log(data.page(1)) //This will give first 100 tracks in playlist.
```
- total_pages `property`
_This give total pages that have been fetched so far._
```js
let data = await spotify(playlist_url)
console.log(data.total_pages) // This will tell no. of pages that have been fetched so far.
for(let i = 1; i <= data.total_pages; i++){
queue.push(data.page(i)) //This will push all tracks to your queue system
}
```
- total_tracks `property`
_This give total videos that have been fetched so far._
```js
let data = await spotify(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_
### SpotifyAlbum
_This is a spotify albun class._
##### fetch() `function`
_This will fetch tracks in a album upto 500 tracks only._
```js
let data = await spotify(playlist_url)
await data.fetch() // Fetches tracks more than 50 tracks in album
```
##### tracksCount `property`
_This will give no. of tracks in a playlist._
```js
let data = await spotify(playlist_url)
console.log(data.tracksCount) // Returns total tracks count in a album
```
##### page(page_number : `number`)
_This will return array of tracks in that page._
> Same as youtube playlist pages
```js
let data = await spotify(playlist_url)
console.log(data.page(1)) //This will give first 50 tracks in album.
```
- total_pages `property`
_This give total pages that have been fetched so far._
```js
let data = await spotify(playlist_url)
console.log(data.total_pages) // This will tell no. of pages that have been fetched so far.
for(let i = 1; i <= data.total_pages; i++){
queue.push(data.page(i)) //This will push all tracks to your queue system
}
```
- total_tracks `property`
_This give total videos that have been fetched so far._
```js
let data = await spotify(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 "album" for this class._
##### toJSON() `function`
_converts class into a json format_

View File

@ -1,198 +0,0 @@
# YouTube
## Basic Usage
```js
const youtube = require('play-dl');
// ES6: import youtube from 'play-dl';
const options = {
limit : 1
}
const results = await youtube.search('post malone sunflower', options);
```
## Validate
### yt_validate(url : `string`)
_This will validate url and return type or boolean_
**Returns :** `video` | `playlist` | `search` | `false`
```js
let check = yt_validate(url)
if(!check) // Invalid URL
if(check === "video") //URL is video url
if(check === "playlist") //URL is a playlist url
if(check === "search") // Given term is not a video ID and PlayList ID.
```
## Extract ID
### extractID(url : `string`)
_This will return videoID or playlistID from a url_
**Note :** URL like [this](https://www.youtube.com/watch?v=E2gHczUOCGI&list=PLUt3leKZfbZqLzLwcQMYPBdbe7i7KRCOP&index=2) will return a playlist ID only.
```js
let id = extractID(url)
```
## Video
### InfoOptions
_This are the info options that can be passed as a parameter in `video_info` and `video_basic_info`_
- proxy : Optional parameter to add support of proxies. As of now, HTTPS proxies are only supported. So make sure to get HTTPS proxies only.
- htmldata : `boolean` Set this to true if you are passing a html body as first parameter.
```js
const video = await video_basic_info(url, { proxy : ['url'] }) // Accepts a url which has port in it.
const video = await video_basic_info(url, {proxy : [{
host : "IP or hostname",
port : 8080
}]
}) // Or add a json containing hostname and port.
// Use any https package to use proxy and then do this
const video = await video_basic_info(body, { htmldata : true }) // You can use video_info function also.
```
### video_basic_info(url : `string`, options? : [`InfoOptions`](https://github.com/play-dl/play-dl/tree/main/docs/YouTube#infooptions))
_The basic video details `play-dl` fetches at first from url or videoID._
```js
const video = await video_basic_info(url)
```
### video_info(url : `string`, , options? : [`InfoOptions`](https://github.com/play-dl/play-dl/tree/main/docs/YouTube#infooptions))
_This contains everything with deciphered formats along with `video_details`. It can fetech data from url or videoID._
```js
const video = await video_info(url)
```
- #### format `property`
_This returns all the formats available for a video._
```js
const video = await video_info(url)
console.log(video.format)
```
### decipher_info(data : `InfoData`)
_This contains everything with deciphered formats along with `video_details`. It uses data returned by [`video_basic_info`](https://github.com/play-dl/play-dl/tree/main/docs/YouTube#video_basic_infourl--string-options--infooptions). This function is useful if you use [`video_basic_info`](https://github.com/play-dl/play-dl/tree/main/docs/YouTube#video_basic_infourl--string-options--infooptions) earlier in your code and want to convert the output for use with [`stream_from_info`](https://github.com/play-dl/play-dl/tree/main/docs#stream_from_infoinfo--infodata-options--streamoptions)_
```js
const basic_video = await video_basic_info(url);
const video = await decipher_info(basic_video);
```
## Playlist
### playlist_info(url : `string`, options : `PlaylistOptions`)
_This fetches all details about a playlist from a url or playlistID._
```js
const playlist = await playlist_info(url)
//This only fetches first 100 videos from a playlist
const playlist = await playlist_info(url, { incomplete : true })
//This only fetches first 100 videos from a playlist and also parses playlist with hidden videos
const playlist = await playlist_info(url, { proxy : [''] }) // Same 2 options as mentioned in InfoOptions
```
- #### fetch() `method`
_This fetches and returns all videos from the whole provided playlist ._
```js
const playlist = await playlist_info(url)
//This only fetches first 100 videos from a playlist
await playlist.fetch()
// This one fetches all videos from a playlist.
```
- #### page(page_number : `number`)
_This returns no. of videos from a page._
> Every 100 videos have been divided into pages.
> Example: There are 782 videos in a playlist, so there will be 8 pages.
```js
const playlist = await playlist_info(url);
// This only fetches first 100 videos from a playlist.
await playlist.fetch();
// This one fetches all videos from a playlist.
console.log(playlist.page(1));
// This displays first 100 videos of a playlist
```
- #### total_pages `property`
_This returns total no. of pages that have been fetched so far._
```js
const playlist = await playlist_info(url)
//This only fetches first 100 videos from a playlist.
await playlist.fetch()
// This one fetches all videos from a playlist.
console.log(playlist.total_pages)
// This displays total no. of pages fetched so far.
for(let i = 1; i <= playlist.total_pages; i++){
queue.push(...playlist.page(i))
} // This will push every video in that playlist to your queue
```
- #### total_videos `property`
_This returns total no. of videos that have been fetched so far._
```js
const playlist = await playlist_info(url)
//This only fetches first 100 videos from a playlist.
await playlist.fetch()
// This one fetches all videos from a playlist.
console.log(playlist.total_videos)
// This displays total no. of videos fetched so far.
```
- #### videoCount `property`
_This returns total no. of videos in the provided playlist._
```js
const playlist = await playlist_info(url)
//This only fetches first 100 videos from a playlist.
await playlist.fetch()
// This one fetches all videos from a playlist.
console.log(playlist.videoCount)
// This displays total no. of videos in a playlist.
```

View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 480 B

After

Width:  |  Height:  |  Size: 480 B

View File

Before

Width:  |  Height:  |  Size: 855 B

After

Width:  |  Height:  |  Size: 855 B

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More