Using get_video on YouTube to download a video

前端 未结 3 914
醉酒成梦
醉酒成梦 2021-02-09 15:26

I am trying to get the video URL of any YouTube video like this:

Open

http://youtube.com/get_video_info?video_id=VIDEOID

then take the

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-09 15:59

    Sorry, that is not possible anymore. They limit the token to the IP that got it.

    Here's a workaround by using the get_headers() function, which gives you an array with the link to the video. I don't know anything about ios, so hopefully you can rewrite this PHP code yourself.

    video_details;
    
        $url_array = array ("http://youtube.com/get_video?video_id=".$id."&t=".$token,
        "http://youtube.com/get_video?video_id=".$id."&t=".$token."&fmt=18");
    
        if(url_exists($url_array[1]) === true) {
            $file = get_headers($url_array[1]);
        }
    
        elseif(url_exists($url_array[0]) === true) {
            $file = get_headers($url_array[0]);
        }
    
        $url = trim($file[19],"Location: ");
    
        echo 'Download video';
    }
    ?>
    

提交回复
热议问题