1

I'm doing a simple (not so simple for me) youtube BBCode that hides the embedded video in a dropdown, for when there's too many embedded videos, to not cause the web browser to lag trying to load them all at the same time.

I want the dropdown to display the video thumbnail (got that sorted) and title.

I don't know much about javascript, and the other questions and answers about this haven't worked for me. Example:Fetching YouTube video title from known video id Maybe I don't know how to implement it.

I just need the script to get the youtube vide title from the id and print it, really.

Community
  • 1
  • 1
Derek89
  • 71
  • 7
  • What errors have you run into while trying the other methods you linked? – Maximillian Laumeister Aug 02 '15 at 19:31
  • I'm afraid I don't know how to check for those errors. I've just copy pasted them with just editing the initial var id so it uses the id provided by the poster. – Derek89 Aug 02 '15 at 19:34
  • 1
    [This answer](http://stackoverflow.com/a/19623573/2234742) might be helpful in learning how to check for JavaScript errors. – Maximillian Laumeister Aug 02 '15 at 19:38
  • 1
    To query the youtube API, I believe you have to register the application and use the key given. The old API would allow anyone to query but as far as i'm aware, they have removed it pushing people to use the V3 API. – NewToJS Aug 02 '15 at 19:44
  • 1
    Here's a link to the 2.0 API you're trying to use. https://developers.google.com/youtube/2.0/developers_guide_protocol_video_entries **The YouTube Data API (v2) has been officially deprecated as of March 4, 2014.** The correct API to use is this one. https://developers.google.com/youtube/v3/code_samples/javascript I hope this helps you. – NewToJS Aug 02 '15 at 19:46
  • Possible duplicate of [Fetching YouTube video title from known video id](http://stackoverflow.com/questions/10596745/fetching-youtube-video-title-from-known-video-id) –  Jan 10 '16 at 22:14
  • Possibly duplicate of http://stackoverflow.com/questions/10596745/fetching-youtube-video-title-from-known-video-id/10597710 –  Jan 10 '16 at 22:16

2 Answers2

1

Edit: YouTube shut down the v2 API in 2015, take a look at the documentation of the new API v3 for a working code.

https://stackoverflow.com/a/30685729/753676

Copied from https://stackoverflow.com/a/10597710/753676

You can do this with plain JavaScript like this:

<script 
type="text/javascript" 
src="https://gdata.youtube.com/feeds/api/videos/videoid?v=2&alt=json-in-script&format=5&callback=getTitle">
</script>

And then:

function getTitle(data) {
 var feed = data.feed;
 var entries = feed.entry || [];
  for (var i = 0; i < entries.length; i++) {
   var entry = entries[i];
   var title = entry.title.$t;
  }
 } 
Community
  • 1
  • 1
0

Unfortunately, since version 3. This is no longer possible with the youtube API without auth.

You can use noembed however without Auth if you want to grab basic info about the video.

I.E http://noembed.com/embed?url=http%3A//www.youtube.com/watch%3Fv%3DbDOYN-6gdRE&callback=my_embed_function

The response is JSON.

Chamilyan
  • 9,347
  • 10
  • 38
  • 67