mirror of
https://github.com/YuzuZensai/play-dl-test.git
synced 2026-01-06 04:32:40 +00:00
Spotify support added
This commit is contained in:
25
docs/README.md
Normal file
25
docs/README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Play-dl commands
|
||||
|
||||
For source specific commands :-
|
||||
- [YouTube]()
|
||||
- [Spotify]()
|
||||
|
||||
### Validate
|
||||
|
||||
#### validate(url : `string`)
|
||||
*This checks all type of urls that are supported by play-dl.*
|
||||
|
||||
**Returns :** `sp_track` | `sp_album` | `sp_playlist` | `yt_video` | `yt_playlist` | `false`
|
||||
|
||||
sp = Spotify
|
||||
|
||||
yt = YouTube
|
||||
```js
|
||||
let check = validate(url)
|
||||
|
||||
if(!check) // Invalid URL
|
||||
|
||||
if(check === 'yt_video') // YouTube Video
|
||||
|
||||
if(check === 'sp_track') // Spotify Track
|
||||
```
|
||||
24
docs/Spotify/README.md
Normal file
24
docs/Spotify/README.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# Spotify
|
||||
|
||||
## Validate
|
||||
### sp_validate(url : `string`)
|
||||
*This checks that given url is spotify url or not.*
|
||||
|
||||
**Returns :** `track` | `album` | `playlist` | `false`
|
||||
```js
|
||||
let check = sp_validate(url)
|
||||
|
||||
if(!check) // Invalid Spotify URL
|
||||
|
||||
if(check === 'track') // Spotify Track URL
|
||||
```
|
||||
|
||||
## Main
|
||||
### spotify(url : `string`)
|
||||
*This returns data from a track | playlist | album url.*
|
||||
|
||||
```js
|
||||
let data = spotify(url) //Gets the data
|
||||
|
||||
console.log(data.type) // Console logs the type of data that you got.
|
||||
```
|
||||
189
docs/YouTube/README.md
Normal file
189
docs/YouTube/README.md
Normal file
@@ -0,0 +1,189 @@
|
||||
# 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` | `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
|
||||
```
|
||||
|
||||
## Stream
|
||||
|
||||
### stream(url : `string`, cookie? : `string`)
|
||||
*This is basic to create a youtube stream from a url.*
|
||||
|
||||
**[Cookies](https://github.com/play-dl/play-dl/discussions/34) are optional and are required for playing age restricted videos.**
|
||||
|
||||
```js
|
||||
let source = await stream("url") // This will create a stream Class which contains type and stream to be played.
|
||||
let resource = createAudioResource(source.stream, {
|
||||
inputType : source.type
|
||||
}) // This creates resource for playing
|
||||
```
|
||||
|
||||
### stream_from_info(info : `infoData`)
|
||||
*This is basic to create a youtube stream from a info [ from [video_info](https://github.com/play-dl/play-dl#video_infourl--string) function ].*
|
||||
```js
|
||||
let info = await video_info("url")
|
||||
let source = await stream_from_info(info) // This will create a stream Class which contains type and stream to be played.
|
||||
let resource = createAudioResource(source.stream, {
|
||||
inputType : source.type
|
||||
}) // This creates resource for playing
|
||||
```
|
||||
|
||||
## Search
|
||||
|
||||
### search(url : `string`, options? : [SearchOptions](https://github.com/play-dl/play-dl/tree/main/play-dl/YouTube#searchoptions))
|
||||
|
||||
*This enables all searching mechanism (video, channel, playlist)*
|
||||
|
||||
```js
|
||||
const options = {
|
||||
limit : 1
|
||||
}
|
||||
const results = await youtube.search('never gonna give you up', options);
|
||||
console.log(results[0].url);
|
||||
```
|
||||
|
||||
- #### SearchOptions
|
||||
- *type* : `video` | `channel` | `playlist`
|
||||
- *limit* : `integer`
|
||||
|
||||
|
||||
|
||||
## Video
|
||||
|
||||
### video_basic_info(url : `string`, cookie? : `string`)
|
||||
*The basic video details `play-dl` fetches at first.*
|
||||
|
||||
**[Cookies](https://github.com/play-dl/play-dl/discussions/34) are optional and are required for playing age restricted videos.**
|
||||
|
||||
```js
|
||||
const video = await video_basic_info(url)
|
||||
```
|
||||
### video_info(url : `string`, cookie? : `string`)
|
||||
*This contains everything with deciphered formats along with `video_details`.*
|
||||
|
||||
**[Cookies](https://github.com/play-dl/play-dl/discussions/34) are optional and are required for playing age restricted videos.**
|
||||
|
||||
```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)
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Playlist
|
||||
|
||||
### playlist_info(url : `string`, parseIncomplete : `boolean`)
|
||||
*This fetches all details about a playlist.*
|
||||
|
||||
**parseIncomplete** is optional parameter if you want to parse playlist with hidden videos.
|
||||
```js
|
||||
const playlist = await playlist_info(url)
|
||||
//This only fetches first 100 videos from a playlist
|
||||
|
||||
const playlist = await playlist_info(url, true)
|
||||
//This only fetches first 100 videos from a playlist and also parses playlist with hidden videos
|
||||
```
|
||||
|
||||
- #### 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++){
|
||||
"Your 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.
|
||||
```
|
||||
Reference in New Issue
Block a user