Files
play-dl-test/docs/README.md

119 lines
4.0 KiB
Markdown
Raw Normal View History

2021-09-05 18:50:57 +05:30
# Play-dl commands
For source specific commands :-
2021-09-21 13:00:38 +05:30
- [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)
2021-09-21 14:52:58 +05:30
- [SoundCloud](https://github.com/play-dl/play-dl/tree/main/docs/SoundCloud)
2021-09-05 18:50:57 +05:30
### Validate
#### validate(url : `string`)
2021-09-21 13:00:38 +05:30
_This checks all type of urls that are supported by play-dl._
**Returns :** `so_playlist` | `so_track` | `sp_track` | `sp_album` | `sp_playlist` | `yt_video` | `yt_playlist` | `false`
`so` = **SoundCloud**
2021-09-05 18:50:57 +05:30
2021-09-21 13:00:38 +05:30
`sp` = **Spotify**
`yt` = **YouTube**
2021-09-05 18:50:57 +05:30
```js
2021-09-21 13:00:38 +05:30
let check = await validate(url)
2021-09-05 18:50:57 +05:30
if(!check) // Invalid URL
if(check === 'yt_video') // YouTube Video
if(check === 'sp_track') // Spotify Track
2021-09-21 13:00:38 +05:30
if(check === 'so_track') // SoundCloud Track
```
### authorization()
_This creates basic spotify / soundcloud 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.
```
2021-09-24 15:13:45 +05:30
### Search
#### SearchOptions :
- limit : `number` :- Sets total amount of results you want.
- source : {
youtube: `video` | `playlist` | `channel` ;
spotify: `album` | `playlist` | `track` ;
soundcloud: `tracks` | `playlists` | `albums` ;
}
2021-09-24 15:27:12 +05:30
#### search(query : `string`, options? : [`SearchOptions`](https://github.com/play-dl/play-dl/tree/main/docs#searchoptions-))
2021-09-24 15:13:45 +05:30
_This is basic to search with any source._
2021-09-24 16:02:03 +05:30
**NOTE :-** If options.source is not specified, then it will default to youtube video search.
2021-09-24 15:13:45 +05:30
```js
2021-09-24 16:02:03 +05:30
let data = await search('Rick Roll', { limit : 1 }) // Searches for youtube video
2021-09-24 15:13:45 +05:30
let data = await search('Rick Roll', { limit : 1, source { youtube : "video" } }) // Searches for youtube video
2021-09-24 18:12:23 +05:30
let data = await search('Rick Roll', { limit: 1, source { spotify : "track" } }) // Searches for spotify track.
2021-09-24 15:13:45 +05:30
2021-09-24 18:12:23 +05:30
let data = await search('Rick Roll', { limit: 1, source { soundcloud : "tracks" } }) // Searches for soundcloud track.
2021-09-24 15:13:45 +05:30
```
2021-09-21 13:00:38 +05:30
### Stream
2021-09-24 15:13:45 +05:30
#### StreamOptions :
2021-09-21 13:00:38 +05:30
2021-09-24 12:49:39 +05:30
- quality : `number` :- Sets quality of stream [ 0 = Lowest, 1 = Medium ]. Leave this empty to get highest audio quality.
2021-09-24 15:13:45 +05:30
- cookie : `string` :- **[Cookies](https://github.com/play-dl/play-dl/discussions/34)** are optional and are required for playing age restricted videos.
2021-09-24 12:49:39 +05:30
2021-09-24 15:27:12 +05:30
#### stream(url : `string`, options? : [`StreamOptions`](https://github.com/play-dl/play-dl/tree/main/docs#streamoptions-))
2021-09-21 13:00:38 +05:30
2021-09-24 12:49:39 +05:30
_This is basic to create a stream from a youtube or soundcloud url._
2021-09-21 13:00:38 +05:30
```js
2021-09-24 15:56:30 +05:30
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", { cookie: COOKIE }) //This will create a stream Class and also give cookies.
2021-09-21 16:01:24 +05:30
2021-09-21 22:04:45 +05:30
let resource = createAudioResource(source.stream, {
2021-09-21 13:00:38 +05:30
inputType : source.type
}) // This creates resource for playing
```
2021-09-24 15:27:12 +05:30
#### stream_from_info(info : `infoData`, options? : [`StreamOptions`](https://github.com/play-dl/play-dl/tree/main/docs#streamoptions-))
2021-09-21 13:00:38 +05:30
2021-09-24 15:27:12 +05:30
_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**] ]._
2021-09-21 13:00:38 +05:30
**Note :** Here, cookies are required only for retrying purposes.
```js
2021-09-24 15:56:30 +05:30
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
2021-09-21 22:04:45 +05:30
2021-09-24 15:56:30 +05:30
let source = await stream_from_info(info, { quality : 1 }) // Next to Lowest quality.
2021-09-24 15:14:49 +05:30
2021-09-24 15:56:30 +05:30
let source = await stream_from_info(info, { cookie: COOKIE }) //This will create a stream Class and also give cookies if retrying.
2021-09-24 15:14:49 +05:30
2021-09-21 22:04:45 +05:30
let resource = createAudioResource(source.stream, {
2021-09-21 13:00:38 +05:30
inputType : source.type
}) // This creates resource for playing
2021-09-05 18:54:16 +05:30
```