Added a fix for 404 errors youtube.

This commit is contained in:
killer069 2021-12-27 12:17:24 +05:30
parent e9ccfb219d
commit 695d9c2daf

View File

@ -1,7 +1,9 @@
import { request_stream } from '../Request';
import { LiveStream, Stream } from './classes/LiveStream'; import { LiveStream, Stream } from './classes/LiveStream';
import { SeekStream } from './classes/SeekStream'; import { SeekStream } from './classes/SeekStream';
import { InfoData, StreamInfoData } from './utils/constants'; import { InfoData, StreamInfoData } from './utils/constants';
import { video_stream_info } from './utils/extractor'; import { video_stream_info } from './utils/extractor';
import { URL } from 'node:url';
export enum StreamType { export enum StreamType {
Arbitrary = 'arbitrary', Arbitrary = 'arbitrary',
@ -81,6 +83,7 @@ export async function stream_from_info(
else final.push(info.format[info.format.length - 1]); else final.push(info.format[info.format.length - 1]);
let type: StreamType = let type: StreamType =
final[0].codec === 'opus' && final[0].container === 'webm' ? StreamType.WebmOpus : StreamType.Arbitrary; final[0].codec === 'opus' && final[0].container === 'webm' ? StreamType.WebmOpus : StreamType.Arbitrary;
await request_stream(`https://${new URL(final[0].url).host}/generate_204`)
if (options.seek) { if (options.seek) {
if (type === StreamType.WebmOpus) { if (type === StreamType.WebmOpus) {
if (options.seek >= info.video_details.durationInSec || options.seek <= 0) if (options.seek >= info.video_details.durationInSec || options.seek <= 0)