Youtube .NET Data API:仅检索videoID? [英] Youtube .NET Data API: Retrieve only videoID?

查看:111
本文介绍了Youtube .NET Data API:仅检索videoID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用youtube的.NET API检索视频供稿,下面是代码:

I am using youtube's .NET API to retrieve video feeds, here is the code:

        String[] ids;
        YouTubeRequestSettings settings = new YouTubeRequestSettings("My App Name", "My App Key");
        YouTubeRequest request = new YouTubeRequest(settings);
        Uri uri =
        new Uri("http://gdata.youtube.com/feeds/api/users/nptelhrd/uploads?max-results=50");//Change "GoogleDevelopers" to "default"
        Google.GData.Client.Feed<Video> videoFeed = request.Get<Video>(uri);
        ids = new String[videoFeed.TotalResults];

        int count = 0;
        for (int i = 0; i < 50; i++)
            ids[i] = videoFeed.Entries.ElementAt(i).VideoId;
        for (int i = 50; i < ids.Length-50; i+=50)
        {

            Uri uri2 =
   new Uri("http://gdata.youtube.com/feeds/api/users/nptelhrd/uploads?max-results=50&start-index=" + i.ToString());//Change "GoogleDevelopers" to "default"
            Google.GData.Client.Feed<Video> videoFeed2 = request.Get<Video>(uri);
            for (int j = 0; j < 50; j++)
            {
                ids[i+j] = videoFeed2.Entries.ElementAt(j).VideoId;
                count++;
            }
        }

上面的代码返回用户"nptelhrd"上传的每个视频的所有信息(标题,描述,ViewCount,评分等).该特定用户上传了6950个视频.

The above code returns every information(Title, Description, ViewCount, Rating....etc.) for each video uploaded by the user "nptelhrd". There are 6950 videos uploaded by this particular user.

以上代码在512Kbps连接上需要15分钟来执行,因为它检索每个视频的所有信息非常缓慢,浪费了大量服务器资源.上面的代码不能修改为仅检索videoId吗?如何只检索所有视频的videoId?

THE ABOVE CODE TAKES 15 MINUTES TO EXECUTE on a 512Kbps connection, because it retrieves all information of each and every video, its painfully slow, wastes a lot of server resources. Can't the above code be modified so that it only retrieve videoId's? How can I only retrieve videoId's of all videos?

推荐答案

由于.NET YOUTUBE API的当前限制,无法仅检索VIDEOID.

With the present limitations of .NET YOUTUBE API, its not possible to retrieve only VIDEOID.

这篇关于Youtube .NET Data API:仅检索videoID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆