Merge pull request #134 from absidue/video-info-from-basic-info
Add decipher_info function
This commit is contained in:
commit
f6957c5926
@ -86,6 +86,16 @@ 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`)
|
||||
|
||||
@ -85,7 +85,7 @@ export async function stream(url: string, options: StreamOptions = {}): Promise<
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Stream command for YouTube using info from video_info function.
|
||||
* Stream command for YouTube using info from video_info or decipher_info function.
|
||||
* @param info video_info data
|
||||
* @param options lets you add quality, cookie, proxy support for stream
|
||||
* @returns Stream class with type and stream for playing.
|
||||
|
||||
@ -2,6 +2,7 @@ import { ProxyOptions as Proxy, request } from './../../Request/index';
|
||||
import { format_decipher } from './cipher';
|
||||
import { YouTubeVideo } from '../classes/Video';
|
||||
import { YouTubePlayList } from '../classes/Playlist';
|
||||
import { InfoData } from '../stream';
|
||||
|
||||
interface InfoOptions {
|
||||
proxy?: Proxy[];
|
||||
@ -176,6 +177,21 @@ export async function video_info(url: string, options: InfoOptions = {}) {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Function uses data from video_basic_info and deciphers it if it contains signatures.
|
||||
* @param data basic_video_info data
|
||||
* @returns Data containing video_details, LiveStreamData and formats of video url.
|
||||
*/
|
||||
export async function decipher_info(data: InfoData) {
|
||||
if (data.LiveStreamData.isLive === true && data.LiveStreamData.hlsManifestUrl !== null) {
|
||||
return data;
|
||||
} else if (data.format[0].signatureCipher || data.format[0].cipher) {
|
||||
data.format = await format_decipher(data.format, data.html5player);
|
||||
return data;
|
||||
} else {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Function to get YouTube playlist info from a playlist url.
|
||||
* @param url Playlist URL
|
||||
|
||||
@ -1 +1,8 @@
|
||||
export { video_basic_info, video_info, playlist_info, yt_validate, extractID } from './extractor';
|
||||
export {
|
||||
video_basic_info,
|
||||
video_info,
|
||||
decipher_info,
|
||||
playlist_info,
|
||||
yt_validate,
|
||||
extractID
|
||||
} from './extractor';
|
||||
|
||||
@ -1,4 +1,13 @@
|
||||
export { playlist_info, video_basic_info, video_info, yt_validate, extractID, YouTube, YouTubeStream } from './YouTube';
|
||||
export {
|
||||
playlist_info,
|
||||
video_basic_info,
|
||||
video_info,
|
||||
decipher_info,
|
||||
yt_validate,
|
||||
extractID,
|
||||
YouTube,
|
||||
YouTubeStream
|
||||
} from './YouTube';
|
||||
export { spotify, sp_validate, refreshToken, is_expired, Spotify } from './Spotify';
|
||||
export { soundcloud, so_validate, SoundCloud, SoundCloudStream } from './SoundCloud';
|
||||
export { setToken } from './token';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user