YouTube finally Completed

This commit is contained in:
killer069
2021-08-16 17:37:44 +05:30
parent d3893e7636
commit 25627526b2
7 changed files with 516 additions and 268 deletions

View File

@@ -1,5 +1,5 @@
import got from "got"
import { video_info } from "."
import { Stream, stream as yt_stream } from "../Stream/stream"
interface FilterOptions {
@@ -44,7 +44,7 @@ function parseFormats(formats : any[]): { audio: any[], video:any[] } {
function filter_songs(formats : any[], options : FilterOptions) {
}
export async function stream(url : string, options? : StreamOptions): Promise<Stream>{
export async function stream(url : string, options? : StreamOptions){
let info = await video_info(url)
let final: any[] = [];
@@ -83,5 +83,5 @@ export async function stream(url : string, options? : StreamOptions): Promise<St
final.push(info.format[info.format.length - 1])
}
return yt_stream(final[0].url)
return got.stream(final[0].url)
}

View File

@@ -1,7 +1,6 @@
import { url_get } from './request'
import { format_decipher, js_tokens } from './cipher'
import { Video } from '../classes/Video'
import { RequestInit } from 'node-fetch'
import { PlayList } from '../classes/Playlist'
const DEFAULT_API_KEY = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8";

View File

@@ -1,12 +1,12 @@
import fetch, { RequestInit } from 'node-fetch'
import got, { OptionsOfTextResponseBody } from 'got/dist/source'
export async function url_get (url : string, options? : RequestInit) : Promise<string>{
export async function url_get (url : string, options? : OptionsOfTextResponseBody) : Promise<string>{
return new Promise(async(resolve, reject) => {
let response = await fetch(url, options)
let response = await got(url, options)
if(response.status === 200) {
resolve(await response.text())
if(response.statusCode === 200) {
resolve(response.body)
}
else reject(`Got ${response.status} from ${url}`)
else reject(`Got ${response.statusCode} from ${url}`)
})
}