Chris
Chris

Reputation: 301

Javascript n00b - Get YouTube API v3 Video Description instead of Title (existing code)

With apologies for asking what I imagine will be a stupid (or seemingly lazy) question. I fully grant you that the problem here lies in my inability to understand JavaScript. I promise you... I'm working on it. I'm learning JS slowly. :) I'm thankful for any help you can give.

I'm using an existing script to create a YouTube playlist.

However, instead of displaying the video's title (which is what the code currently does), I want to display the video's description.

I really thought this would be easy. But alas... it's beyond me.

With hope that this doesn't bring an onslaught of -1's... Chris

function(dummy_code_so_I_can_post_a_JSfiddle-link){};

http://jsfiddle.net/nk9a1dyh/

Upvotes: 0

Views: 247

Answers (2)

logikal
logikal

Reputation: 1141

The element you are looking to target is:

var d=e.entry["media$group"]["media$description"].$t;

see updated (still horrible) jsfiddle: http://jsfiddle.net/nk9a1dyh/3/

Hope this helps.

Upvotes: 1

theWanderer4865
theWanderer4865

Reputation: 871

I think you are trying to make this far more complicated then it has to be.

First off, try to get your HTML together - it is the scaffold you will run your JS on.

Second, making an API call in JS from the browser can be quite difficult so take baby steps. Start off installing NodeJS and use the http or requests library to make a simple request to the YouTube API. Here is a simple example to show you what you are doing:

var http = require("http");
var my_response = http.get("http://google.com/");
console.log(my_response)

Really take the time to understand all the stuff in this JSON object. Things like status code, content-type, headers, all of these things mean something important to how your application can know what is happening.

Once you are comfortable, look in the Videos resource in the API docs and see what you get back when you make a get request. Once you are comfortable with using the API, then you can move on to making your application do work.

Upvotes: 1

Related Questions