Reputation: 2110
Consider Youtube API XML files like http://gdata.youtube.com/feeds/api/videos/$id One particular XML data file is http://gdata.youtube.com/feeds/api/videos/GI6CfKcMhjY The following function gets the title of the video according to the XML url:
function ytTitle($ytid,$ytURLConstant){
$url = $ytURLConstant.$ytid;
$doc = new DOMDocument;
$doc->load($url);
echo $title = $doc->getElementsByTagName("title")->item(0)->nodeValue;
}
As I see there is video duration in the XML file:
<media:title type='plain'>Jack Sparrow (feat. Michael Bolton)</media:title><yt:duration seconds='197'/>
As I am an XML newbie any help concerning getting the video duration will be greatly appreciated.
Upvotes: 1
Views: 6097
Reputation: 97
I had a similar problem with Youtube API and I find this very helpful site
http://viewsboard.com/boards/view/discussion/2/263
Upvotes: 2