mirror of
https://github.com/YuzuZensai/play-dl-test.git
synced 2026-01-31 14:58:05 +00:00
Video Info bug fixes and stream improvements
This commit is contained in:
@@ -151,7 +151,7 @@ export async function video_basic_info(url: string, options: InfoOptions = {}):
|
||||
const player_data = body
|
||||
.split('var ytInitialPlayerResponse = ')?.[1]
|
||||
?.split(';</script>')[0]
|
||||
.split(/;\s*(var|const|let)\s/)[0];
|
||||
.split(/(?<=}}});\s*(var|const|let)\s/)[0];
|
||||
if (!player_data) throw new Error('Initial Player Response Data is undefined.');
|
||||
const initial_data = body
|
||||
.split('var ytInitialData = ')?.[1]
|
||||
@@ -349,7 +349,7 @@ export async function video_stream_info(url: string, options: InfoOptions = {}):
|
||||
const player_data = body
|
||||
.split('var ytInitialPlayerResponse = ')?.[1]
|
||||
?.split(';</script>')[0]
|
||||
.split(/;\s*(var|const|let)\s/)[0];
|
||||
.split(/(?<=}}});\s*(var|const|let)\s/)[0];
|
||||
if (!player_data) throw new Error('Initial Player Response Data is undefined.');
|
||||
const player_response = JSON.parse(player_data);
|
||||
let upcoming = false;
|
||||
|
||||
@@ -146,7 +146,7 @@ export function parseVideo(data?: any): YouTubeVideo {
|
||||
id: data.videoRenderer.videoId,
|
||||
url: `https://www.youtube.com/watch?v=${data.videoRenderer.videoId}`,
|
||||
title: data.videoRenderer.title.runs[0].text,
|
||||
description: data.videoRenderer.detailedMetadataSnippets?.[0].snippetText.runs.length
|
||||
description: data.videoRenderer.detailedMetadataSnippets?.[0].snippetText.runs?.length
|
||||
? data.videoRenderer.detailedMetadataSnippets[0].snippetText.runs.map((run: any) => run.text).join('')
|
||||
: '',
|
||||
duration: durationText ? parseDuration(durationText.simpleText) : 0,
|
||||
|
||||
Reference in New Issue
Block a user