После исследования того, как я получаю этот код от StackOverflow
И работает хорошо
Для этого идентификатора видео = 6chhghoMGVQ
Но когда я добавляю это видео ID Tseries VFTSW817JlI
У меня появляется сообщение об ошибке Status => UNPLAYABLE
Вот ссылка на рабочий код для этого идентификатора видео = 6chhghoMGVQ
проблема с подписью, когда я хочу получить прямой URL с YouTube через PHP
Наконец, я изменил некоторые ссылки по этой ссылке https://www.youtube.com/get_video_info?sts=18177&video_id=$v&asv=3&el=detailpage&hl=en_US&eurl=https://youtube.googleapis.com/v/$v
Вместо этой ссылки https://www.youtube.com/get_video_info?video_id=$v
После изменения ссылки I Got Status For Video UNPLAYABLE TO OK
НО Теперь я не могу получить URL, потому что здесьЯвляется ли URL-адрес cipher
, если я изменяю
"url" => $array["streamingData"]["formats"][$a]["url"],
["url"] на шифр, я получаю URL-адрес, но не воспроизводимый URL-адрес Получить сообщение об ошибке 403
У меня старый кодировщик шифрования подписиНо не работает
Вот код, который я пробовал.
<?php
function YT_IN_DX($url){
$cookie_file_path = "cookies.txt";
$agent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/46.0";
$ch = curl_init();
$headers[] = "Connection: Keep-Alive";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_URL, $url);
$res = curl_exec($ch);
curl_close($ch);
return $res;
}
function YT_V_INFO($v){
$url = "https://www.youtube.com/get_video_info?sts=18177&video_id=$v&asv=3&el=detailpage&hl=en_US&eurl=https://youtube.googleapis.com/v/$v";
$html = urldecode(YT_IN_DX($url));
$video_links = Explode_Content('playabilityStatus', 'adSafetyReason', $html);
$json = str_replace("\u0026", "&", $video_links);
$json = '{"playabilityStatus' . $json . 'adSafetyReason":{"isEmbed":true}}';
$array = json_decode($json, true);
if (isset($array["playabilityStatus"]["status"]) && $array["playabilityStatus"]["status"] == "UNPLAYABLE") {
$data = array("error" => $array["playabilityStatus"]["status"]);
}else{
$formats = $array["streamingData"]["formats"];
for ($a = 0; $a <= (count($formats) - 1); $a++){
$data[] = array(
"url" => $array["streamingData"]["formats"][$a]["url"],
"mimeType" => $array["streamingData"]["formats"][$a]["mimeType"],
"quality" => $array["streamingData"]["formats"][$a]["quality"],
"qualityLabel" => $array["streamingData"]["formats"][$a]["qualityLabel"],
"width" => $array["streamingData"]["formats"][$a]["width"],
"height" => $array["streamingData"]["formats"][$a]["height"],
"audioQuality" => $array["streamingData"]["formats"][$a]["audioQuality"],
"approxDurationMs" => $array["streamingData"]["formats"][0]["approxDurationMs"]
);
}
}
return $data;
}
function Explode_Content($first, $last, $string)
{
$exp = explode($first, $string);
$exp = explode($last, $exp[1]);
return $exp[0];
}
// $videoinfo=YT_V_INFO("sJsoyuQAepQ");
$videoinfo = YT_V_INFO("VFTSW817JlI");
echo '<pre>';
print_r($videoinfo);
?>
Вот кодировщик подписи
function decrypt_sig($s,$algo) {
$method = explode(" ",$algo);
foreach($method as $m)
{
if($m == 'r')
$s = strrev($s);
else if( substr($m,0,1) == 's')
$s = substr($s, (int) substr($m,1) );
else if( substr($m,0,1) == 'w')
$s = swap($s, (int) substr($m,1));
}
return $s;
}
function swap($a, $b) {
$c = $a[0];
$a[0] = $a[$b % strlen($a)];
$a[$b] = $c;
return $a;
}
Algo Keys: {"sts":"18177","algo":"r w22 s3 w42 r"}