From d8ffb077e1fc29ed385ccc15e5e09a5b1054efe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Fri, 11 Dec 2020 22:32:47 -0500 Subject: Fix Undefined variable --- tools/extract.php | 121 +++++++++++++++++++++++++++++----------------------- tools/processor.php | 1 + 2 files changed, 68 insertions(+), 54 deletions(-) diff --git a/tools/extract.php b/tools/extract.php index 2f82387..97cad90 100644 --- a/tools/extract.php +++ b/tools/extract.php @@ -425,38 +425,84 @@ if ( isset($streamin_data_json["videoDetails"]["keywords"]) ) { // streams if (isset($streamin_data_json["streamingData"])) { - $strF=$streamin_data_json["streamingData"]["formats"]; - $strA=$streamin_data_json["streamingData"]["adaptiveFormats"]; + if (isset($streamin_data_json["streamingData"]["formats"])) { + $strF=$streamin_data_json["streamingData"]["formats"]; + } + + if (isset($streamin_data_json["streamingData"]["adaptiveFormats"])) { + $strA=$streamin_data_json["streamingData"]["adaptiveFormats"]; + } $vdef = array(); - foreach ($strF as $stream) { - if (isset($stream["signatureCipher"])) { - parse_str($stream["signatureCipher"],$dturl); - $values = array( - 'url' => $dturl['url'].'&sig='.sig($dturl['s']), - 'itag' => $stream['itag'], - 'type' => $stream['mimeType'], - 'quality' => $stream['quality'], - 'fps' => $stream['fps'], - 'resolution' => $stream['qualityLabel'], - 'qualityLabel' => $stream['qualityLabel'], - 'format' => exformat($stream['itag']) - ); - array_push($vdef, $values); - } else { - if (!empty($strF['url'])) { + if (isset($strF)) { + foreach ($strF as $stream) { + if (isset($stream["signatureCipher"])) { + parse_str($stream["signatureCipher"],$dturl); $values = array( - 'url' => $strF['url'], + 'url' => $dturl['url'].'&sig='.sig($dturl['s']), + 'itag' => $stream['itag'], + 'type' => $stream['mimeType'], + 'quality' => $stream['quality'], + 'fps' => $stream['fps'], + 'resolution' => $stream['qualityLabel'], + 'qualityLabel' => $stream['qualityLabel'], + 'format' => exformat($stream['itag']) ); array_push($vdef, $values); + } else { + if (!empty($strF['url'])) { + $values = array( + 'url' => $strF['url'], + ); + array_push($vdef, $values); + } } } } + $aud = array(); $vid = array(); - foreach ($strF as $stream) { - if (isset( $stream['url'] )) { + if (isset($strF)) { + foreach ($strF as $stream) { + if (isset( $stream['url'] )) { + if (preg_match('/video/', $stream['mimeType'])) { + $url = $stream['url']; + $values = array( + 'url' => $url, + 'itag' => $stream['itag'], + 'type' => $stream['mimeType'], + 'quality' => $stream['quality'], + 'fps' => $stream['fps'], + 'resolution' => $stream['qualityLabel'], + 'qualityLabel' => $stream['qualityLabel'], + 'format' => exformat($stream['itag']), + ); + array_push($vid, $values); + } + } + } + } + + if (isset($strA)) { + foreach ($strA as $stream) { + if (isset($stream["signatureCipher"])) { + parse_str($stream["signatureCipher"],$dturl); + $stream['url']=$dturl['url'].'&sig='.sig($dturl['s']); + } + + if (preg_match('/audio/', $stream['mimeType'])) { + $url = $stream['url']; + $values = array( + 'url' => $url, + 'itag' => $stream['itag'], + 'type' => $stream['mimeType'], + 'quality' => $stream['quality'], + 'format' => exformat($stream['itag']), + ); + array_push($aud, $values); + } + if (preg_match('/video/', $stream['mimeType'])) { $url = $stream['url']; $values = array( @@ -473,39 +519,6 @@ if (isset($streamin_data_json["streamingData"])) { } } } - foreach ($strA as $stream) { - if (isset($stream["signatureCipher"])) { - parse_str($stream["signatureCipher"],$dturl); - $stream['url']=$dturl['url'].'&sig='.sig($dturl['s']); - } - - if (preg_match('/audio/', $stream['mimeType'])) { - $url = $stream['url']; - $values = array( - 'url' => $url, - 'itag' => $stream['itag'], - 'type' => $stream['mimeType'], - 'quality' => $stream['quality'], - 'format' => exformat($stream['itag']), - ); - array_push($aud, $values); - } - - if (preg_match('/video/', $stream['mimeType'])) { - $url = $stream['url']; - $values = array( - 'url' => $url, - 'itag' => $stream['itag'], - 'type' => $stream['mimeType'], - 'quality' => $stream['quality'], - 'fps' => $stream['fps'], - 'resolution' => $stream['qualityLabel'], - 'qualityLabel' => $stream['qualityLabel'], - 'format' => exformat($stream['itag']), - ); - array_push($vid, $values); - } - } } else { $vdef = array(); diff --git a/tools/processor.php b/tools/processor.php index 5918873..d442234 100644 --- a/tools/processor.php +++ b/tools/processor.php @@ -52,6 +52,7 @@ if (!empty($vdef)) { } else { $streamFormats = $vid; $streamExtra = FALSE; + $streamFormatsExtra = NULL; } $videoAuthor = $vidauthor; -- cgit v1.2.3