Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从youtube音乐视频中提取歌曲和艺术家_Php_Youtube Api - Fatal编程技术网

Php 从youtube音乐视频中提取歌曲和艺术家

Php 从youtube音乐视频中提取歌曲和艺术家,php,youtube-api,Php,Youtube Api,我正在制作一个网站,你可以从youtube上搜索或播放音乐视频,并在网站上播放。 有一个问题。我无法正确地从youtube上提取歌曲和艺术家。 我做了这个功能: $watch = $_GET['var']; //id of the video $code = $watch; // Get video feed info (xml) from youtube, but only the title | http://php.net/manual/en/function.file-get-conte

我正在制作一个网站,你可以从youtube上搜索或播放音乐视频,并在网站上播放。 有一个问题。我无法正确地从youtube上提取歌曲和艺术家。 我做了这个功能:

$watch = $_GET['var'];
//id of the video
$code = $watch;
// Get video feed info (xml) from youtube, but only the title | http://php.net/manual/en/function.file-get-contents.php
$video_feed = file_get_contents("http://gdata.youtube.com/feeds/api/videos?v=2&q=".$code."&max-results=1&fields=entry(title)&prettyprint=true");
// xml to object | http://php.net/manual/en/function.simplexml-load-string.php
$video_obj = simplexml_load_string($video_feed);
// Get the title string to a variable
$video_str = $video_obj->entry->title;
// Output
echo "<br/>\n";
$new =  explode("-", $video_str);
$watch是youtube视频id。 youtube上的官方音乐视频是这样的。阿姆-没有我
我能得到这首歌和艺术家的唯一方法就是这样。然而,音乐视频的格式是不同的。标题中没有-,所以我无法从youtube上提取我需要的信息。我想知道是否还有其他方法可以做到这一点

我不确定YT是否通过API公开。我对围绕这一点展开的工作的最佳猜测是拥有不同的艺术家数据库,然后匹配标题或其他元数据项以提取艺术家。
您需要一些机制来维护和更新艺术家数据库以及与之相关的视频

您始终可以通过在上处理原始xml来提取艺术家

http://gdata.youtube.com/feeds/api/videos/{$videoId}

没有更有效的2021年解决方案?