如何从YouTube观看记录中获取最新视频

时间:2012-09-18 20:52:52

标签: c# api youtube

我想从YouTube观看历史记录中获取最新视频。我使用以下代码,但视频大小总是不同的,很少等于100.如何解决此问题?

YouTubeRequestSettings ytSettings = new YouTubeRequestSettings(AppKey, DevKey, currentLogin, currentPassword);
ytSettings.PageSize = 10;
ytSettings.AutoPaging = true;
YouTubeRequest ytRequest = new YouTubeRequest(ytSettings);

string uri = "https://gdata.youtube.com/feeds/api/users/default/watch_history?v=2";
Feed<Video> videos = ytRequest.Get<Video>(new Uri(uri));
List<string> vids = new List<string>();

foreach (Video vid in videos.Entries)
{
    if (vids.Count < 100)
    {
        vids.Add(vid.VideoId.ToString());
    }
    else
    {
        break;
    }
}

1 个答案:

答案 0 :(得分:0)

我正在粘贴链接,以便有人可能会发现它对他们的知识有用

http://www.codeproject.com/Articles/143669/Manage-YouTube-using-C-and-Youtube-API

<强>更新 嗨我从谷歌开发者那里得到了链接。为.NET定义了四种方法。所以我们要挖掘最近上传的内容。因为我看不到.NET最近的视频标题

https://developers.google.com/youtube/v3/code_samples/dotnet

https://github.com/youtube/api-samples/tree/master/dotnet