mirror of
https://github.com/YuzuZensai/play-dl-test.git
synced 2026-01-31 14:58:05 +00:00
https Feature added
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { PassThrough } from 'stream'
|
||||
import got from 'got'
|
||||
import { IncomingMessage } from 'http';
|
||||
import { StreamType } from '../stream';
|
||||
import Request from 'got/dist/source/core';
|
||||
import { request, request_stream } from '../utils/request';
|
||||
import { video_info } from '..';
|
||||
|
||||
export interface FormatInterface{
|
||||
@@ -21,7 +21,7 @@ export class LiveStreaming{
|
||||
private video_url : string
|
||||
private dash_timer : NodeJS.Timer | null
|
||||
private segments_urls : string[]
|
||||
private request : Request | null
|
||||
private request : IncomingMessage | null
|
||||
constructor(dash_url : string, target_interval : number, video_url : string){
|
||||
this.type = StreamType.Arbitrary
|
||||
this.url = dash_url
|
||||
@@ -53,8 +53,8 @@ export class LiveStreaming{
|
||||
}
|
||||
|
||||
private async dash_getter(){
|
||||
let response = await got(this.url)
|
||||
let audioFormat = response.body.split('<AdaptationSet id="0"')[1].split('</AdaptationSet>')[0].split('</Representation>')
|
||||
let response = await request(this.url)
|
||||
let audioFormat = response.split('<AdaptationSet id="0"')[1].split('</AdaptationSet>')[0].split('</Representation>')
|
||||
if(audioFormat[audioFormat.length - 1] === '') audioFormat.pop()
|
||||
this.base_url = audioFormat[audioFormat.length - 1].split('<BaseURL>')[1].split('</BaseURL>')[0]
|
||||
let list = audioFormat[audioFormat.length - 1].split('<SegmentList>')[1].split('</SegmentList>')[0]
|
||||
@@ -90,8 +90,8 @@ export class LiveStreaming{
|
||||
if(Number(segment.split('sq/')[1].split('/')[0]) !== this.packet_count){
|
||||
continue
|
||||
}
|
||||
await new Promise((resolve, reject) => {
|
||||
let stream = got.stream(this.base_url + segment)
|
||||
await new Promise(async(resolve, reject) => {
|
||||
let stream = await request_stream(this.base_url + segment)
|
||||
this.request = stream
|
||||
stream.pipe(this.stream, { end : false })
|
||||
stream.on('end', () => {
|
||||
@@ -118,7 +118,7 @@ export class Stream {
|
||||
private content_length : number;
|
||||
private data_ended : boolean;
|
||||
private playing_count : number;
|
||||
private request : Request | null
|
||||
private request : IncomingMessage | null
|
||||
constructor(url : string, type : StreamType, duration : number, contentLength : number){
|
||||
this.url = url
|
||||
this.type = type
|
||||
@@ -155,13 +155,13 @@ export class Stream {
|
||||
this.per_sec_bytes = 0
|
||||
}
|
||||
|
||||
private loop(){
|
||||
private async loop(){
|
||||
if(this.stream.destroyed){
|
||||
this.cleanup()
|
||||
return
|
||||
}
|
||||
let end : number = this.bytes_count + this.per_sec_bytes * 300;
|
||||
let stream = got.stream(this.url, {
|
||||
let stream = await request_stream(this.url, {
|
||||
headers : {
|
||||
"range" : `bytes=${this.bytes_count}-${end >= this.content_length ? '' : end}`
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { getPlaylistVideos, getContinuationToken } from "../utils/extractor";
|
||||
import { url_get } from "../utils/request";
|
||||
import { request } from "../utils/request";
|
||||
import { Thumbnail } from "./Thumbnail";
|
||||
import { Channel } from "./Channel";
|
||||
import { Video } from "./Video";
|
||||
@@ -62,7 +62,7 @@ export class PlayList{
|
||||
async next(limit: number = Infinity): Promise<Video[]> {
|
||||
if (!this._continuation || !this._continuation.token) return [];
|
||||
|
||||
let nextPage = await url_get(`${BASE_API}${this._continuation.api}`, {
|
||||
let nextPage = await request(`${BASE_API}${this._continuation.api}`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
continuation: this._continuation.token,
|
||||
|
||||
Reference in New Issue
Block a user