开发者

Youtube API - Retrieving videos through GDATA to slow

开发者 https://www.devze.com 2023-02-14 16:03 出处:网络
I have a function that gets a video item from youtube, below is the http webclient call that gets the xml:

I have a function that gets a video item from youtube, below is the http webclient call that gets the xml:

        Dim request As String = String.Format("http://gdata.youtube.com/feeds/api/videos/{0}?restriction=us", id)开发者_开发知识库
        Dim responseByte() As Byte = Me.WebClient.DownloadData(request)
        Dim responseXML As String = System.Text.UTF8Encoding.UTF8.GetString(responseByte)

The reason i decided to create the functionality to get videos this way rather than using Youtubes API framework was becuase it was to slow.

Now when i did it this way with my own functionality is was faster BUT a big BUT its still slow. If i display 24 videos on a page it takes all together when getting each video information from the xml a total ammount of arround 24 seconds. this is a real overhead, 24 seconds just to recieve 24 videos is too long and if i want to display more videos it will take longer.

So the question is is there a faster way to recieve video information from youtube?

All i want to extraxt is the:

Title ImageUrl Artist Duration


Add the fields querystring parameter, then followed by the elements you want to extract:

    Dim request2 As String = String.Format("http://gdata.youtube.com/feeds/api/videos/{0}?fields=title,media:group/yt:duration,media:group/media:thumbnail&restriction=us", id)

Doing it this way halfed the result time, quicker but would like it to be much faster than this approach still. Does anyone know of a quicker methodd or is this the only answer?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号