0

I have this script in my website: video feed

As you can see there is no additional info. However I managed to show the video title with:

html.push('<li onclick="loadVideo(\'', playerUrl, '\', true)">',
                  '<img src="', 
                  thumbnailUrl, '" width="116" height="76"/> <span> ',title,' </span> </li>');

My question is: How can I show more than the title of the video, like stats: number of views, video link, additional uploader content etc. I don't need everything of course but it would be nice to show a bit more than just the video title. I have read the api documents(find here) but could not find anything, however I'm no expert so I could have overlooked something.

Thanks

Youss
  • 4,196
  • 12
  • 55
  • 109
  • Okay, I'm currently reading this:http://code.google.com/intl/nl-NL/apis/youtube/2.0/developers_guide_protocol.html#Displaying_information_about_a_video .....Hope it will make some sense to me.. – Youss May 14 '11 at 13:52

3 Answers3

1

you need this: http://code.google.com/intl/nl-NL/apis/youtube/2.0/developers_guide_protocol.html#Retrieve_video_entry

http://gdata.youtube.com/feeds/api/videos/videoid?v=2

use on this an xml parser (xml2array) and read the data or do it with json?

  • +1 But while that might work but the OP doesn't want to retrieve data for just a single video and it doesn't look like it's necessary to go about it this way. – no.good.at.coding May 14 '11 at 15:20
  • well you can combine it with asynchronous cURL (php), thats how i did it for an video portal using youtube api –  May 14 '11 at 15:26
  • Right, but I was trying to point out that it might not be necessary to get information per video since the feed the OP is using seems to have most of this information already. – no.good.at.coding May 14 '11 at 15:53
  • the google api should be serve enough infos and there are also some other api requests for different uses (feeds for all videos by the same youtube user, feeds for one video, feeds for one playlist ...) well at the end he has just to extract the whole info right out from the feed using an xml parser or json –  May 14 '11 at 16:04
  • Hi, I tried doing that with no luck. Thank's for your effort anyway. – Youss May 15 '11 at 06:52
  • This is the complete list on modifications for the feed(url)http://code.google.com/intl/nl-NL/apis/youtube/2.0/developers_guide_protocol.html#Searching_for_Videos – Youss May 15 '11 at 07:01
1

If you look at the JSON response, you're already getting most of the information. Take a look at the reference documentation that lists out all the data and tags that are returned. You'll want to look for the equivalent JSON elements yourself since they don't seem to be documented.

For example, the description is available as the <media:description> tag in XML which shows up as the media$description element in JSON. The <yt:rating> tag has the number of likes and dislikes. However, note that the deprecated gd$rating is still used in the JSON.

no.good.at.coding
  • 20,221
  • 2
  • 60
  • 51
  • Hi, I tried what you are suggesting but it doesn't work. I have been doing a bit of research and I found this code(for rating): Rating rating = videoEntry.getRating(); if(rating != null) { System.out.println("Average rating: " + rating.getAverage()); } this is the url:http://proxyserver.si/Glype/browse.php?u=Oi8vY29kZS5nb29nbGUuY29tL2ludGwvbmwtTkwvYXBpcy95b3V0dWJlLzEuMC9kZXZlbG9wZXJzX2d1aWRlX2phdmEuaHRtbA%3D%3D&b=13 I just don't now hot to put it together. I would appreciate any help on this. – Youss May 15 '11 at 06:45
  • Oh and I als found this guy claiming he can get the number of views with: videoEntry.getStatistics().getViewCount(); the url:http://groups.google.com/group/youtube-api-gdata/browse_thread/thread/e5dc86e317f28b8a/7b8123bd835edabd?lnk=gst&q=views#7b8123bd835edabd I just don't now how to put two and two together. – Youss May 15 '11 at 06:57
0

First of all thank you guys for taking the time and effort to help me out. Because my programming skills are that of a newbie( I actualy just learned html,css) it could be that you guys have provided me with a good answer but because I'm new at this I didn't understand. So that said...

I have been looking around on the internet and I found this script

It was not what I was looking for, I could not merge it with my current script. But than I looked at the js and there it was. So I just copied and paste and it works fine now. This is what I was looking for:

var title = entry.title.$t.substr(0, 40);
var viewcount = entry.yt$statistics.viewCount;
var comments = entry.content.$t;

Again, thank you all very much.

Youss
  • 4,196
  • 12
  • 55
  • 109
  • Good for you - however, you're right, that the answers kinda pointed at the same thing - they didn't give you the code but they pointed you to the documentation. It's important to be able to refer to the documentation and find what you need since you might not always find code doing what you need. Good luck! – no.good.at.coding May 15 '11 at 14:59