some LiveStream fixes
This commit is contained in:
parent
eb06c74759
commit
c0615659ac
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "play-dl",
|
"name": "play-dl",
|
||||||
"version": "0.2.7",
|
"version": "0.3.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "play-dl",
|
"name": "play-dl",
|
||||||
"version": "0.2.6",
|
"version": "0.3.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"got": "^11.8.2"
|
"got": "^11.8.2"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "play-dl",
|
"name": "play-dl",
|
||||||
"version": "0.2.7",
|
"version": "0.3.0",
|
||||||
"description": "YouTube, SoundCloud, Spotify downloader",
|
"description": "YouTube, SoundCloud, Spotify downloader",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
|
|||||||
@ -42,6 +42,8 @@ export async function stream(url : string, options : StreamOptions = { actual_li
|
|||||||
let info = await video_info(url)
|
let info = await video_info(url)
|
||||||
let final: any[] = [];
|
let final: any[] = [];
|
||||||
let type : StreamType;
|
let type : StreamType;
|
||||||
|
if(!options.actual_live) options.actual_live = false
|
||||||
|
if(!options.preferred_quality) options.preferred_quality = "144p"
|
||||||
if(info.LiveStreamData.isLive === true && info.LiveStreamData.hlsManifestUrl !== null) {
|
if(info.LiveStreamData.isLive === true && info.LiveStreamData.hlsManifestUrl !== null) {
|
||||||
return await live_stream(info as InfoData, options)
|
return await live_stream(info as InfoData, options)
|
||||||
}
|
}
|
||||||
@ -69,6 +71,8 @@ export async function stream(url : string, options : StreamOptions = { actual_li
|
|||||||
export async function stream_from_info(info : InfoData, options : StreamOptions = { actual_live : false, preferred_quality : "144p" }): Promise<Stream | LiveStreaming | LiveEnded>{
|
export async function stream_from_info(info : InfoData, options : StreamOptions = { actual_live : false, preferred_quality : "144p" }): Promise<Stream | LiveStreaming | LiveEnded>{
|
||||||
let final: any[] = [];
|
let final: any[] = [];
|
||||||
let type : StreamType;
|
let type : StreamType;
|
||||||
|
if(!options.actual_live) options.actual_live = false
|
||||||
|
if(!options.preferred_quality) options.preferred_quality = "144p"
|
||||||
if(info.LiveStreamData.isLive === true && info.LiveStreamData.hlsManifestUrl !== null) {
|
if(info.LiveStreamData.isLive === true && info.LiveStreamData.hlsManifestUrl !== null) {
|
||||||
return await live_stream(info as InfoData, options)
|
return await live_stream(info as InfoData, options)
|
||||||
}
|
}
|
||||||
@ -113,10 +117,10 @@ async function live_stream(info : InfoData, options : StreamOptions): Promise<Li
|
|||||||
})
|
})
|
||||||
let stream : LiveStreaming | LiveEnded
|
let stream : LiveStreaming | LiveEnded
|
||||||
if(info.video_details.duration === '0') {
|
if(info.video_details.duration === '0') {
|
||||||
stream = new LiveStreaming((res_144.url.length !== 0) ? res_144 : info.format[info.format.length - 1], options.actual_live)
|
stream = new LiveStreaming((res_144.url.length !== 0) ? res_144 : info.format[info.format.length - 2], options.actual_live)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stream = new LiveEnded((res_144.url.length !== 0) ? res_144 : info.format[info.format.length - 1])
|
stream = new LiveEnded((res_144.url.length !== 0) ? res_144 : info.format[info.format.length - 2])
|
||||||
}
|
}
|
||||||
return stream
|
return stream
|
||||||
}
|
}
|
||||||
@ -58,15 +58,15 @@ export async function video_basic_info(url : string){
|
|||||||
|
|
||||||
export async function video_info(url : string) {
|
export async function video_info(url : string) {
|
||||||
let data = await video_basic_info(url)
|
let data = await video_basic_info(url)
|
||||||
if(data.format[0].signatureCipher || data.format[0].cipher){
|
if(data.LiveStreamData.isLive === true && data.LiveStreamData.hlsManifestUrl !== null){
|
||||||
data.format = await format_decipher(data.format, data.html5player)
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
else if(data.LiveStreamData.isLive === true && data.LiveStreamData.hlsManifestUrl !== null){
|
|
||||||
let m3u8 = await url_get(data.LiveStreamData.hlsManifestUrl)
|
let m3u8 = await url_get(data.LiveStreamData.hlsManifestUrl)
|
||||||
data.format = await parseM3U8(m3u8, data.format)
|
data.format = await parseM3U8(m3u8, data.format)
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
else if(data.format[0].signatureCipher || data.format[0].cipher){
|
||||||
|
data.format = await format_decipher(data.format, data.html5player)
|
||||||
|
return data
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user