我正在尝试将 Youtube 视频直接下载到托管空间。当我在本地服务器(例如我的 PC 上的 xampp)上尝试该脚本时,它运行良好。但是当我在 000webhosting 上尝试该脚本时,它不起作用。它显示这样的错误
错误如下。
呃哦,好像发生了错误:无法找到 MP4 视频源。
下面是下载 Youtube 视频的 PHP 代码。
<?php
// What YouTube URL was provided to us?
$url = (string) @$_GET['url'];
/**
* Define a function to extract a YouTube Video ID from a URL.
*
* @param string $url A YouTube Video URL
* @return mixed If successful, will return a string. If failed, will return NULL
*/
function getYouTubeVideoIdFromUrl( $url )
{
preg_match( "/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:m\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&\"'>]+)/", $url, $matches ); …Run Code Online (Sandbox Code Playgroud)