What's the best way to get the title of a Youtube video?

+1 Jesse Cox · January 4, 2015
Working on a site which integrates tightly into Youtube. Need to know how to get video titles. Thanks guys.

Post a Reply

Replies

Oldest  Newest  Rating
+1 Sam Dahal · January 11, 2015
We can use php to get youtube title given the id of the video. Use XML data to get the title of youtube through php

<?php

$id = 'LZLDHPWqpWw';
$feed = simplexml_load_string(file_get_contents("http://gdata.youtube.com/feeds/api/videos/{$id}?fields=title"));
$title = (string)$feed->title;

echo $title;
?>
0 Viral Joshi · January 4, 2015
Use Python to crawl page and get title text. I am not sure crawling youtube is allowed or not so make sure you are following all T&C of youtube before doing anything. Caz, its all Google and you may get in trouble. ;) Enjoy codes.
0 Jesse Cox · January 4, 2015
OK thanks
0 Vraj Patel · January 4, 2015
Posting that question on the Javascript forum would be nice. I am not really an expert @ javascript so cant help you there bud, sorry. 
0 Jesse Cox · January 4, 2015
Is there a way I can do it with Javascript? IE getting the title of the iframe youtube embeds for each video?
0 Vraj Patel · January 4, 2015
In bold below you will see a HTML tag that goes along with every youtube page containing a video. This tag identifies the title of the video if you want to see this for yourself you can right click on the title of a youtube video inside google chrome and click inspect element. 


<span id="eow-title" class="watch-title long-title" dir="ltr" title="Paul Rudd Talks Edgar Wright Exit From Ant Man - Comic Con 2014">
    Paul Rudd Talks Edgar Wright Exit From Ant Man - Comic Con 2014
  </span>

This code was taken from:
https://www.youtube.com/watch?v=h4xcLf5Prx8 
  • 1

PHP

107,313 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators