【问题标题】:extracting song and artist from youtube music video从 youtube 音乐视频中提取歌曲和艺术家
【发布时间】:2012-12-04 16:44:51
【问题描述】:

我正在制作一个网站,您可以从 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上的官方音乐视频是这样的。 "eminem - without me" 我能得到这首歌和艺术家的唯一方法就是这样。但是对于音乐视频,格式是不同的。标题中没有“ - ”,所以我无法从 youtube 中提取我需要的信息。我想知道是否有其他方法可以做到这一点。

【问题讨论】:

    标签: php youtube-api


    【解决方案1】:

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

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

    【讨论】:

    • 没有更多可用的
    • 任何 2021 年的解决方案?
    【解决方案2】:

    我不确定 YT 是否通过 API 公开 artist information。我对解决此问题的最佳猜测是拥有一个不同的艺术家数据库,然后匹配标题或其他元数据项以提取艺术家。

    您需要一些机制来维护和更新艺术家数据库并将视频与之相关联。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-09
      • 2011-05-22
      • 1970-01-01
      • 1970-01-01
      • 2017-03-01
      • 2016-04-22
      • 2013-03-21
      • 1970-01-01
      相关资源
      最近更新 更多