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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵