<small id='9sOfq'></small><noframes id='9sOfq'>

    • <bdo id='9sOfq'></bdo><ul id='9sOfq'></ul>
      <legend id='9sOfq'><style id='9sOfq'><dir id='9sOfq'><q id='9sOfq'></q></dir></style></legend>
    1. <i id='9sOfq'><tr id='9sOfq'><dt id='9sOfq'><q id='9sOfq'><span id='9sOfq'><b id='9sOfq'><form id='9sOfq'><ins id='9sOfq'></ins><ul id='9sOfq'></ul><sub id='9sOfq'></sub></form><legend id='9sOfq'></legend><bdo id='9sOfq'><pre id='9sOfq'><center id='9sOfq'></center></pre></bdo></b><th id='9sOfq'></th></span></q></dt></tr></i><div id='9sOfq'><tfoot id='9sOfq'></tfoot><dl id='9sOfq'><fieldset id='9sOfq'></fieldset></dl></div>

      1. <tfoot id='9sOfq'></tfoot>

        当我想通过 PHP 从 YouTube 获取直接 URL 时的签名问题

        signature issue when I want to get a direct URL from YouTube via PHP(当我想通过 PHP 从 YouTube 获取直接 URL 时的签名问题)

          <tfoot id='ZInq9'></tfoot>
            <tbody id='ZInq9'></tbody>
        • <small id='ZInq9'></small><noframes id='ZInq9'>

            <bdo id='ZInq9'></bdo><ul id='ZInq9'></ul>
            • <legend id='ZInq9'><style id='ZInq9'><dir id='ZInq9'><q id='ZInq9'></q></dir></style></legend>
                  <i id='ZInq9'><tr id='ZInq9'><dt id='ZInq9'><q id='ZInq9'><span id='ZInq9'><b id='ZInq9'><form id='ZInq9'><ins id='ZInq9'></ins><ul id='ZInq9'></ul><sub id='ZInq9'></sub></form><legend id='ZInq9'></legend><bdo id='ZInq9'><pre id='ZInq9'><center id='ZInq9'></center></pre></bdo></b><th id='ZInq9'></th></span></q></dt></tr></i><div id='ZInq9'><tfoot id='ZInq9'></tfoot><dl id='ZInq9'><fieldset id='ZInq9'></fieldset></dl></div>

                1. 本文介绍了当我想通过 PHP 从 YouTube 获取直接 URL 时的签名问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在研究我如何从 YouTube 视频中获取直接 URL 之后,问:

                  更新:

                  代码:gist.github

                  有什么解决办法吗?非常感谢

                  解决方案

                  这是另一个代码,用于从 youtube get_video_info

                  获取每个视频质量

                   $array["playabilityStatus"]["status"]);}别的{$formats = $array["streamingData"]["formats"];for ($a = 0; $a <= (count($formats) - 1); $a++){$数据[] = 数组(网址"=>$array["streamingData"]["formats"][$a]["url"],mimeType" =>$array["streamingData"]["formats"][$a]["mimeType"],质量" =>$array["streamingData"]["formats"][$a]["quality"],质量标签"=>$array["streamingData"]["formats"][$a]["qualityLabel"],宽度" =>$array["streamingData"]["formats"][$a]["width"],高度" =>$array["streamingData"]["formats"][$a]["height"],音频质量"=>$array["streamingData"]["formats"][$a]["audioQuality"],"approxDurationMs" =>$array["streamingData"]["formats"][0]["approxDurationMs"]);}}返回 $data;}函数 Explode_Content($first, $last, $string){$exp =explode($first, $string);$exp =explode($last, $exp[1]);返回 $exp[0];}$videoinfo = YT_V_INFO("6chhghoMGVQ");//$videoinfo=YT_V_INFO("sJsoyuQAepQ");print_r($videoinfo);?>

                  如果所有者不允许,使用此方法您将无法获取某些视频 ID 数据.这是两个例子:

                  $videoinfo = YT_V_INFO("6chhghoMGVQ");

                  输出:

                  数组([0] =>大批([网址] =>https://r4---sn-p5h-gc5d.googlevideo.com/videoplayback?id=e9c861821a0c1954&itag=18&source=youtube&requiressl=yes&mm=31,26&mn=sn-p5h-gc5d,sn-hpa7znsd&ms=au,onr&mv=m&pl=21&ei=fmWRXLGxLIKZ1wb61YyIBQ&susc=yt&initcwndbps=232500&mime=video/mp4&8&1&1amp;yes4276.271&lmt=1448537568788216&mt=1553032481&fvip=4&c=WEB&ip=196.64.208.187&ipbits=0&ipbits=0&expire,expi5,ipsgre=1553032481&fvip=4&c=WEB&ip=196.64.208.187&ipbits,mm,mn,ms,mv,pl,ei,susc,initcwndbps,mime,gir,clen,ratebypass,dur,lmt&signature=E2DEC9FF027D3810BF4309AD81E1C22E51BDA8F8.DCA10F844A267F75D85D267F75D85D1B85D1B55D1D[mimeType] =>视频/mp4;编解码器=avc1.42001E,mp4a.40.2"[质量] =>中等的[质量标签] =>360p[宽度] =>640[高度] =>360[音频质量] =>AUDIO_QUALITY_LOW[approxDurationMs] =>276271)[1] =>大批([网址] =>https://r4---sn-p5h-gc5d.googlevideo.com/videoplayback?id=e9c861821a0c1954&itag=22&source=youtube&requiressl=yes&mm=31,26&mn=sn-p5h-gc5d,sn-hpa7znsd&ms=au,onr&mv=m&pl=21&ei=fmWRXLGxLIKZ1wb61YyIBQ&susc=yt&initcwndbps=232500&mime=video/mp4&ratebypass;4&1241&4&13&7&13&7&4012121213=1553032481&fvip=4&c=WEB&ip=196.64.208.187&ipbits=0&expire=1553054174&sparams=ip,ipbits,expire,id,itag,mm,mvsnslpl,ei,susc,initcwndbps,mime,ratebypass,dur,lmt&signature=B99844F18562D76976B29A1E6358A3C6D6A0DA78.CD747441B3C6883D3639B5080tCBD8ACCE[mimeType] =>视频/mp4;编解码器=avc1.64001F,mp4a.40.2"[质量] =>高清720[质量标签] =>720p[宽度] =>1280[高度] =>720[音频质量] =>AUDIO_QUALITY_MEDIUM[approxDurationMs] =>276271)[2] =>大批([网址] =>https://r4---sn-p5h-gc5d.googlevideo.com/videoplayback?id=e9c861821a0c1954&itag=43&source=youtube&requiressl=yes&mm=31,26&mn=sn-p5h-gc5d,sn-hpa7znsd&ms=au,onr&mv=m&pl=21&ei=fmWRXLGxLIKZ1wb61YyIBQ&susc=yt&initcwndbps=232500&mime=video/webm&9&pl=21&ei=fmWRXLGxLIKZ1wb61YyIBQ&susc=yt&initcwndbps=232500&mime=video/webm&92&lenrate=yes&9&3;amp;80.000&lmt=1448363037942780&mt=1553032481&fvip=4&c=WEB&ip=196.64.208.187&ipbits=0&expire5,sips,expire=1575430mm,mn,ms,mv,pl,ei,susc,initcwndbps,mime,gir,clen,ratebypass,dur,lmt&signature=B477F9D1D7A34ECFAF8C7CDBC94A46B365633A26.DEC0E305375CCC60000000000000000000000000000000000000000000000000000000000000000000000000000000[mimeType] =>视频/网络视频;编解码器 =vp8.0,vorbis"[质量] =>中等的[质量标签] =>360p[宽度] =>640[高度] =>360[音频质量] =>AUDIO_QUALITY_MEDIUM[approxDurationMs] =>276271))

                  这是所有者不允许的另一个视频 ID.

                  $videoinfo=YT_V_INFO("sJsoyuQAepQ");

                  输出:

                  <块引用>

                  数组 ([错误] => 无法播放)

                  after research to how i get direct URL from YouTube videos like this one asking : How to get direct URL of video from YouTube URL? [closed]

                  i finally made a simple script to generate a direct URL from YouTube video with php and it works just fine, but not with all videos

                  it doesn't work with "signature" videos,

                  this is my code:

                  if(isset($_GET['url']) && $_GET['url'] != ""){
                      parse_str( parse_url( $_GET['url'], PHP_URL_QUERY ), $vars );
                  
                  
                      $id=$vars['v'];
                      $dt=file_get_contents("https://www.youtube.com/get_video_info?video_id=$id&el=embedded&ps=default&eurl=&gl=US&hl=en");
                      //var_dump(explode("&",$dt));
                      if (strpos($dt, 'status=fail') !== false) {
                  
                          $x=explode("&",$dt);
                          $t=array(); $g=array(); $h=array();
                  
                          foreach($x as $r){
                              $c=explode("=",$r);
                              $n=$c[0]; $v=$c[1];
                              $y=urldecode($v);
                              $t[$n]=$v;
                          }
                  
                              $x=explode("&",$dt);
                              foreach($x as $r){
                                  $c=explode("=",$r);
                                  $n=$c[0]; $v=$c[1];
                                  $h[$n]=urldecode($v);
                              }
                              $g[]=$h;
                              $g[0]['error'] = true;
                              $g[0]['instagram'] = "egy.js";
                              $g[0]['apiMadeBy'] = 'El-zahaby';
                          echo json_encode($g,JSON_PRETTY_PRINT);
                  
                      }else{
                  
                          $x=explode("&",$dt);
                          $t=array(); $g=array(); $h=array();
                  
                          foreach($x as $r){
                              $c=explode("=",$r);
                              $n=$c[0]; $v=$c[1];
                              $y=urldecode($v);
                              $t[$n]=$v;
                          }
                          $streams = explode(',',urldecode($t['url_encoded_fmt_stream_map']));
                          foreach($streams as $dt){ 
                              $x=explode("&",$dt);
                              foreach($x as $r){
                                  $c=explode("=",$r);
                                  $n=$c[0]; $v=$c[1];
                                  $h[$n]=urldecode($v);
                              }
                              $g[]=$h;
                          }
                          echo json_encode($g,JSON_PRETTY_PRINT);
                         // var_dump( $g[1]["quality"],true);
                      }
                  }else{
                      @$myObj->error = true;
                      $myObj->msg = "there is no youtube link";
                  
                      $myObj->madeBy = "El-zahaby";
                      $myObj->instagram = "egy.js";
                      $myJSON = json_encode($myObj,JSON_PRETTY_PRINT);
                  
                      echo $myJSON;
                  
                  }
                  

                  example of issue : https://you-link.herokuapp.com/?url=yt.com?v=csy7cF1T2vk

                  update:

                  the code on : gist.github

                  any solution ? thanks a lot

                  解决方案

                  This is another code to get each video qualities from youtube get_video_info

                  <?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?video_id=$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("6chhghoMGVQ");
                  // $videoinfo=YT_V_INFO("sJsoyuQAepQ");
                  print_r($videoinfo);
                  
                  ?>
                  

                  With this method you can't get some videos ID data, if not allowed by owner. this is two examples :

                  $videoinfo = YT_V_INFO("6chhghoMGVQ");
                  

                  Output :

                  Array
                  (
                      [0] => Array
                          (
                              [url] => https://r4---sn-p5h-gc5d.googlevideo.com/videoplayback?id=e9c861821a0c1954&itag=18&source=youtube&requiressl=yes&mm=31,26&mn=sn-p5h-gc5d,sn-hpa7znsd&ms=au,onr&mv=m&pl=21&ei=fmWRXLGxLIKZ1wb61YyIBQ&susc=yt&initcwndbps=232500&mime=video/mp4&gir=yes&clen=13861924&ratebypass=yes&dur=276.271&lmt=1448537568788216&mt=1553032481&fvip=4&c=WEB&ip=196.64.208.187&ipbits=0&expire=1553054174&sparams=ip,ipbits,expire,id,itag,source,requiressl,mm,mn,ms,mv,pl,ei,susc,initcwndbps,mime,gir,clen,ratebypass,dur,lmt&signature=E2DEC9FF027D3810BF4309AD81E1C22E51BDA8F8.DCA10F844A294D5D267F518DBF0951B757855D2B&key=yt8
                              [mimeType] => video/mp4; codecs="avc1.42001E, mp4a.40.2"
                              [quality] => medium
                              [qualityLabel] => 360p
                              [width] => 640
                              [height] => 360
                              [audioQuality] => AUDIO_QUALITY_LOW
                              [approxDurationMs] => 276271
                          )
                  
                      [1] => Array
                          (
                              [url] => https://r4---sn-p5h-gc5d.googlevideo.com/videoplayback?id=e9c861821a0c1954&itag=22&source=youtube&requiressl=yes&mm=31,26&mn=sn-p5h-gc5d,sn-hpa7znsd&ms=au,onr&mv=m&pl=21&ei=fmWRXLGxLIKZ1wb61YyIBQ&susc=yt&initcwndbps=232500&mime=video/mp4&ratebypass=yes&dur=276.271&lmt=1470942139723144&mt=1553032481&fvip=4&c=WEB&ip=196.64.208.187&ipbits=0&expire=1553054174&sparams=ip,ipbits,expire,id,itag,source,requiressl,mm,mn,ms,mv,pl,ei,susc,initcwndbps,mime,ratebypass,dur,lmt&signature=B99844F18562D76976B29A1E6358A3C6D6A0DA78.CD747441B3C6883D3639B584BDACC4023C0A9082&key=yt8
                              [mimeType] => video/mp4; codecs="avc1.64001F, mp4a.40.2"
                              [quality] => hd720
                              [qualityLabel] => 720p
                              [width] => 1280
                              [height] => 720
                              [audioQuality] => AUDIO_QUALITY_MEDIUM
                              [approxDurationMs] => 276271
                          )
                  
                      [2] => Array
                          (
                              [url] => https://r4---sn-p5h-gc5d.googlevideo.com/videoplayback?id=e9c861821a0c1954&itag=43&source=youtube&requiressl=yes&mm=31,26&mn=sn-p5h-gc5d,sn-hpa7znsd&ms=au,onr&mv=m&pl=21&ei=fmWRXLGxLIKZ1wb61YyIBQ&susc=yt&initcwndbps=232500&mime=video/webm&gir=yes&clen=16923548&ratebypass=yes&dur=0.000&lmt=1448363037942780&mt=1553032481&fvip=4&c=WEB&ip=196.64.208.187&ipbits=0&expire=1553054174&sparams=ip,ipbits,expire,id,itag,source,requiressl,mm,mn,ms,mv,pl,ei,susc,initcwndbps,mime,gir,clen,ratebypass,dur,lmt&signature=B477F9D1D7A34ECFAF8C7CDBC94A46B365633A26.DEC0E30537E6DE02FD960E515CC5DDB4CFEFC65C&key=yt8
                              [mimeType] => video/webm; codecs="vp8.0, vorbis"
                              [quality] => medium
                              [qualityLabel] => 360p
                              [width] => 640
                              [height] => 360
                              [audioQuality] => AUDIO_QUALITY_MEDIUM
                              [approxDurationMs] => 276271
                          )
                  
                  )
                  

                  This is another video ID not allowed by his owner.

                  $videoinfo=YT_V_INFO("sJsoyuQAepQ");
                  

                  Output :

                  Array ( [error] => UNPLAYABLE )

                  这篇关于当我想通过 PHP 从 YouTube 获取直接 URL 时的签名问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                    <tfoot id='Ndae9'></tfoot>
                    <i id='Ndae9'><tr id='Ndae9'><dt id='Ndae9'><q id='Ndae9'><span id='Ndae9'><b id='Ndae9'><form id='Ndae9'><ins id='Ndae9'></ins><ul id='Ndae9'></ul><sub id='Ndae9'></sub></form><legend id='Ndae9'></legend><bdo id='Ndae9'><pre id='Ndae9'><center id='Ndae9'></center></pre></bdo></b><th id='Ndae9'></th></span></q></dt></tr></i><div id='Ndae9'><tfoot id='Ndae9'></tfoot><dl id='Ndae9'><fieldset id='Ndae9'></fieldset></dl></div>
                      <tbody id='Ndae9'></tbody>
                      • <legend id='Ndae9'><style id='Ndae9'><dir id='Ndae9'><q id='Ndae9'></q></dir></style></legend>

                          <bdo id='Ndae9'></bdo><ul id='Ndae9'></ul>

                            <small id='Ndae9'></small><noframes id='Ndae9'>