douzao9845 2015-07-13 16:40 采纳率: 0%
浏览 135
已采纳

获取YouTube视频上传者[已关闭]

I've been searching on how to get a YouTube video's uploader and found that I had to use YouTube Data v3 API.

The thing is: I don't want to use any API key nor have any kind of restrictions while performing queries. Is there any way to do so?

  • 写回答

1条回答 默认 最新

  • dongque8332 2015-07-13 16:40
    关注

    Yes, get_video_info is available so you can read the needed information from it. There is no official documentation for it, though.

    function ParseQueryString($query)
    {
        $query = iconv(mb_detect_encoding($query, mb_detect_order(), true), "UTF-8", $query);
        $params = explode('&', $query);
        $args = array();
        foreach ($params as $param)
        {
            $value = explode('=', $param);
            $args[$value[0]] = $value[1];
        }
    
        return $args;
    }
    
    function GetArgs($args, $key, $query)
    {
        $iqs = strpos($args, $query);
        $querystring = "";
    
        if ($iqs != -1)
        {
            $querystring = ($iqs < strlen($args) - 1) ? substr($args, $iqs + 1) : "";
            $nvcArgs = ParseQueryString($querystring);
            return $nvcArgs[$key];
        }
    
        return "";
    }
    
    function GetVideoUploader($url)
    {
        $id = GetArgs($url, "v", '?');
        return GetArgs(file_get_contents("http://youtube.com/get_video_info?video_id=" . $id), "author", '&');
    }
    

    The function GetVideoUploader first retrieves the videoID from the input URL and then uses the videoID to get the video author (aka uploader). GetArgs function can also be used for retrieving a lot of other information from a YouTube video and without need for an API key, such as: download link, length, title, thumbnail and much more. The GetArgs function needs the output from get_video_info in $args, the parameter what you want to find in $key and the '&' symbol in $query.

    You can get a list of parameters by accessing http://youtube.com/get_video_info?video_id=iNJdPyoqt8U (as example), opening it with Notepad++ and replacing '&' character by ' '.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题
  • ¥20 oracle RAC 怎么配置啊,配置
  • ¥15 excel 日常使用中出现问题
  • ¥20 pdusession建立失败
  • ¥15 为什么mqtt接收不到数据?
  • ¥15 思科校园网的组建,sos!
  • ¥15 主要进行描述非满管状态下,管路的摩阻系数是怎么变化的,在管路长度方向上是怎么分布的(标签-matlab)
  • ¥15 multisim设计求解如图
  • ¥15 动态多目标优化,求解定义的问题的POF和POS公式
  • ¥30 实验 :UML2.0 行为建模