Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

extracting song and artist from youtube music video

$
0
0

I am making a website, you can search or music video from youtube and play them on the website.There's one problem. I cant extract the song and the artist from youtube properly.I made this function:

$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;// Outputecho "<br/>\n";$new =  explode("-", $video_str);

$watch is the youtube video id.the official music videos on youtube are like this: eminem - without methe only way I could get the song and artist was like this. However for music videos the format is different. There is no " - " in the title, so I can't extract the information I need from youtube. I was wondering if there is any other way possible to do this.


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>