本文整理汇总了C#中YouTubeRequest.GetSubscriptionsFeed方法的典型用法代码示例。如果您正苦于以下问题:C# YouTubeRequest.GetSubscriptionsFeed方法的具体用法?C# YouTubeRequest.GetSubscriptionsFeed怎么用?C# YouTubeRequest.GetSubscriptionsFeed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YouTubeRequest
的用法示例。
在下文中一共展示了YouTubeRequest.GetSubscriptionsFeed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetListOfSubscriptions
internal List<KeyValuePair<string, List<Video>>> GetListOfSubscriptions(Settings i_settings)
{
List<KeyValuePair<string, List<Video>>> resObj = new List<KeyValuePair<string, List<Video>>> ();
YouTubeRequestSettings settings = new YouTubeRequestSettings(
i_settings.appName
, i_settings.devKey
, i_settings.username
, i_settings.password);
YouTubeRequest request = new YouTubeRequest(settings);
Feed<Subscription> feedOfSubcr = request.GetSubscriptionsFeed(i_settings.userShort);
string[] stringSeparators = new string[] { "Activity of:" };
foreach (Subscription subItem in feedOfSubcr.Entries)
{
string keyStr = subItem.ToString().Split(stringSeparators, StringSplitOptions.None)[1].Trim();
List<Video> listOfVideos = new List<Video>();
string userName = subItem.UserName;
string url = string.Format(i_settings.urlFormatter, userName);
Feed<Video> videoFeed = request.Get<Video>(new Uri(url));
int depth = 0;
foreach (Video entry in videoFeed.Entries)
{
//strBuilder.AppendLine(" " + entry.Title);
listOfVideos.Add(entry);
depth++;
if (depth >= i_settings.feedDepth)
{
break;
}
}
if (listOfVideos.Count > 0)
{
KeyValuePair<string, List<Video>> subscriptionO = new KeyValuePair<string, List<Video>>(keyStr, listOfVideos);
resObj.Add(subscriptionO);
}
}
return resObj;
}
示例2: YouTubeSubscriptionsTest
public void YouTubeSubscriptionsTest()
{
Tracing.TraceMsg("Entering YouTubeSubscriptionsTest");
string playlistID = "4A3A73D5172EB90A";
YouTubeRequestSettings settings = new YouTubeRequestSettings(this.ApplicationName, this.ytClient, this.ytDevKey, this.ytUser, this.ytPwd);
// settings.PageSize = 15;
YouTubeRequest f = new YouTubeRequest(settings);
// this returns the server default answer
Feed<Subscription> feed = f.GetSubscriptionsFeed(null);
foreach (Subscription s in feed.Entries)
{
Assert.IsTrue(s.PlaylistId != null, "There should be a PlaylistId");
Assert.IsTrue(s.PlaylistTitle != null, "There should be a PlaylistTitle");
if (s.PlaylistId == playlistID)
{
f.Delete(s);
}
}
Subscription sub = new Subscription();
sub.Type = SubscriptionEntry.SubscriptionType.playlist;
sub.PlaylistId = playlistID;
f.Insert(feed, sub);
// this returns the server default answer
feed = f.GetSubscriptionsFeed(null);
List<Subscription> list = new List<Subscription>();
foreach (Subscription s in feed.Entries)
{
Assert.IsTrue(s.PlaylistId != null, "There should be a PlaylistId");
Assert.IsTrue(s.PlaylistTitle != null, "There should be a PlaylistTitle");
if (s.PlaylistId == playlistID)
{
list.Add(s);
}
}
Assert.IsTrue(list.Count > 0, "There should be one subscription matching");
foreach (Subscription s in list)
{
f.Delete(s);
}
foreach (Subscription s in feed.Entries)
{
Assert.IsTrue(s.PlaylistId != null, "There should be a PlaylistId");
Assert.IsTrue(s.PlaylistTitle != null, "There should be a PlaylistTitle");
Assert.IsFalse(s.PlaylistId == playlistID, "They should be gone");
}
}
示例3: YouTubeSubscriptionsTest
public void YouTubeSubscriptionsTest() {
Tracing.TraceMsg("Entering YouTubeSubscriptionsTest");
string channelUsername = "GoogleDevelopers";
YouTubeRequestSettings settings = new YouTubeRequestSettings(this.ApplicationName, this.ytDevKey, this.ytUser, this.ytPwd);
YouTubeRequest f = new YouTubeRequest(settings);
// this returns the server default answer
Feed<Subscription> feed = f.GetSubscriptionsFeed(null);
foreach (Subscription s in feed.Entries) {
if (!string.IsNullOrEmpty(s.UserName) && s.UserName == channelUsername) {
f.Delete(s);
}
}
Subscription sub = new Subscription();
sub.Type = SubscriptionEntry.SubscriptionType.channel;
sub.UserName = "GoogleDevelopers";
f.Insert(feed, sub);
// this returns the server default answer
feed = f.GetSubscriptionsFeed(null);
List<Subscription> list = new List<Subscription>();
foreach (Subscription s in feed.Entries) {
if (!string.IsNullOrEmpty(s.UserName) && s.UserName == channelUsername) {
list.Add(s);
}
}
Assert.IsTrue(list.Count > 0, "There should be one subscription matching");
foreach (Subscription s in list) {
f.Delete(s);
}
feed = f.GetSubscriptionsFeed(null);
int iCount = 0;
foreach (Subscription s in feed.Entries) {
iCount++;
}
Assert.IsTrue(iCount == 0, "There should be no subscriptions in the feed");
}