1
/* Copyright (c) 2006 Google Inc.
3
* Licensed under the Apache License, Version 2.0 (the "License");
4
* you may not use this file except in compliance with the License.
5
* You may obtain a copy of the License at
7
* http://www.apache.org/licenses/LICENSE-2.0
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the License for the specific language governing permissions and
13
* limitations under the License.
19
using System.Collections;
22
using Google.GData.Client;
23
using Google.GData.Extensions;
24
using Google.GData.YouTube;
25
using Google.GData.Extensions.MediaRss;
26
using System.Collections.Generic;
28
namespace Google.YouTube
30
public class Complaint : Entry
33
/// creates the inner contact object when needed
35
/// <returns></returns>
36
protected override void EnsureInnerObject()
38
if (this.AtomEntry == null)
40
this.AtomEntry = new ComplaintEntry();
44
/// readonly accessor to the typed underlying atom object
46
public ComplaintEntry ComplaintEntry
50
return this.AtomEntry as ComplaintEntry;
55
/// set's the type of the complaint
57
public ComplaintEntry.ComplaintType Type
61
if (this.ComplaintEntry != null)
63
return this.ComplaintEntry.Type;
65
return ComplaintEntry.ComplaintType.UNKNOWN;
70
this.ComplaintEntry.Type = value;
75
/// sets the verbose part of the complain, stored in the yt:content element
77
public string ComplaintDescription
81
if (this.ComplaintEntry != null)
83
return this.ComplaintEntry.Complaint;
90
this.ComplaintEntry.Complaint = value;
99
/// the Comment entry for a Comments Feed, a feed of Comment for YouTube
101
public class Comment : Entry
104
/// creates the inner contact object when needed
106
/// <returns></returns>
107
protected override void EnsureInnerObject()
109
if (this.AtomEntry == null)
111
this.AtomEntry = new CommentEntry();
116
/// readonly accessor to the underlying CommentEntry object.
118
public CommentEntry CommentEntry
122
return this.AtomEntry as CommentEntry;
127
/// adds the replyToLinks to this comment
130
/// <param name="c">The comment this comment is replying to</param>
131
public void ReplyTo(Comment c)
134
c.CommentEntry == null)
136
throw new ArgumentNullException("c can not be null or c.CommentEntry can not be null");
139
if (this.CommentEntry != null)
141
this.CommentEntry.ReplyTo(c.CommentEntry);
151
/// the subscription entry for a subscriptionfeed Feed
153
public class Subscription : Entry
156
/// readonly accessor for the SubscriptionEntry that is underneath this object.
158
/// <returns></returns>
159
public SubscriptionEntry SubscriptionEntry
163
return this.AtomEntry as SubscriptionEntry;
169
/// creates the inner contact object when needed
171
/// <returns></returns>
172
protected override void EnsureInnerObject()
174
if (this.AtomEntry == null)
176
this.AtomEntry = new SubscriptionEntry();
184
/// returns the subscription type
186
/// <returns></returns>
187
public SubscriptionEntry.SubscriptionType Type
192
return this.SubscriptionEntry.Type;
198
this.SubscriptionEntry.Type = value;
204
/// The user who is the owner of this subscription
206
public string UserName
211
return this.SubscriptionEntry.UserName;
216
this.SubscriptionEntry.UserName = value;
221
/// if the subscripiton is a keyword query, this will be the
222
/// subscripted to query term
224
public string QueryString
229
return this.SubscriptionEntry.QueryString;
235
this.SubscriptionEntry.QueryString = value;
240
/// the id of the playlist you are subscriped to
242
public string PlaylistId
247
return this.SubscriptionEntry.PlaylistId;
253
this.SubscriptionEntry.PlaylistId = value;
258
/// the human readable name of the playlist you are subscribed to
260
public string PlaylistTitle
265
return this.SubscriptionEntry.PlaylistTitle;
271
this.SubscriptionEntry.PlaylistTitle = value;
278
/// the Activity entry for an Activities Feed, a feed of activities for the friends/contacts
279
/// of the logged in user
281
/// <returns></returns>
282
public class Activity : Entry
287
/// creates the inner contact object when needed
289
/// <returns></returns>
290
protected override void EnsureInnerObject()
292
if (this.AtomEntry == null)
294
this.AtomEntry = new ActivityEntry();
299
/// readonly accessor for the YouTubeEntry that is underneath this object.
301
/// <returns></returns>
302
public ActivityEntry ActivityEntry
306
return this.AtomEntry as ActivityEntry;
312
/// specifies a unique ID that YouTube uses to identify a video.
314
/// <returns></returns>
315
public string VideoId
320
if (this.ActivityEntry.VideoId != null)
322
return this.ActivityEntry.VideoId.Value;
329
/// the type of the activity
331
public ActivityType Type
336
return this.ActivityEntry.Type;
341
/// the username of the friend who was added,
342
/// or the user whom was subscribed to
344
public string Username
349
if (this.ActivityEntry.Username != null)
351
return this.ActivityEntry.Username.Value;
359
/// the Playlist entry for a Playlist Feed, a feed of Playlist for YouTube
361
public class Playlist : Entry
365
/// creates the inner contact object when needed
367
/// <returns></returns>
368
protected override void EnsureInnerObject()
370
if (this.AtomEntry == null)
372
this.AtomEntry = new PlaylistsEntry();
377
/// returns the internal atomentry as a PlayListsEntry
379
/// <returns></returns>
380
public PlaylistsEntry PlaylistsEntry
384
return this.AtomEntry as PlaylistsEntry;
389
/// specifies the number of entries in a playlist feed. This tag appears in the entries in a
390
/// playlists feed, where each entry contains information about a single playlist.
392
/// <returns></returns>
398
return this.PlaylistsEntry.CountHint;
404
//////////////////////////////////////////////////////////////////////
405
/// <summary>the Video Entry in feed<Videos> for YouTube
407
//////////////////////////////////////////////////////////////////////
408
public class Video : Entry
413
/// creates the inner contact object when needed
415
/// <returns></returns>
416
protected override void EnsureInnerObject()
418
if (this.AtomEntry == null)
420
this.AtomEntry = new YouTubeEntry();
426
/// readonly accessor for the YouTubeEntry that is underneath this object.
428
/// <returns></returns>
429
public YouTubeEntry YouTubeEntry
433
return this.AtomEntry as YouTubeEntry;
438
/// specifies a unique ID that YouTube uses to identify a video.
440
/// <returns></returns>
441
public string VideoId
446
return this.YouTubeEntry.VideoId;
451
this.YouTubeEntry.VideoId = value;
457
/// contains a summary or description of a video. This field is required in requests to
458
/// upload or update a video's metadata. The description should be sentence-based,
459
/// rather than a list of keywords, and may be displayed in search results. The description has a
460
/// maximum length of 5000 characters and may contain all valid UTF-8 characters except < and >
462
/// <returns></returns>
463
public string Description
467
if (this.YouTubeEntry != null &&
468
this.YouTubeEntry.Media != null &&
469
this.YouTubeEntry.Media.Description != null)
471
return this.YouTubeEntry.Media.Description.Value;
478
if (this.YouTubeEntry.Media == null)
480
this.YouTubeEntry.Media = new Google.GData.YouTube.MediaGroup();
482
if (this.YouTubeEntry.Media.Description == null)
484
this.YouTubeEntry.Media.Description = new MediaDescription();
486
this.YouTubeEntry.Media.Description.Value = value;
492
/// the title of the Video. Overloaded to keep entry.title and the media.title
495
/// <returns></returns>
496
public override string Title
506
if (this.YouTubeEntry.Media == null)
508
this.YouTubeEntry.Media = new Google.GData.YouTube.MediaGroup();
510
if (this.YouTubeEntry.Media.Title == null)
512
this.YouTubeEntry.Media.Title = new MediaTitle();
514
this.YouTubeEntry.Media.Title.Value = value;
520
/// returns the categories for the video
522
/// <returns></returns>
523
public ExtensionCollection<MediaCategory> Tags
528
if (this.YouTubeEntry.Media == null)
530
this.YouTubeEntry.Media = new Google.GData.YouTube.MediaGroup();
532
return this.YouTubeEntry.Media.Categories;
537
/// returns the keywords for the video, see MediaKeywords for more
539
/// <returns></returns>
540
public string Keywords
544
if (this.YouTubeEntry != null)
546
if (this.YouTubeEntry.Media != null)
548
if (this.YouTubeEntry.Media.Keywords != null)
550
return this.YouTubeEntry.Media.Keywords.Value;
559
if (this.YouTubeEntry.Media == null)
561
this.YouTubeEntry.Media = new Google.GData.YouTube.MediaGroup();
563
if (this.YouTubeEntry.Media.Keywords == null)
565
this.YouTubeEntry.Media.Keywords = new MediaKeywords();
567
this.YouTubeEntry.Media.Keywords.Value = value;
573
/// returns the collection of thumbnails for the vido
575
/// <returns></returns>
576
public ExtensionCollection<MediaThumbnail> Thumbnails
580
if (this.YouTubeEntry != null)
582
if (this.YouTubeEntry.Media == null)
584
this.YouTubeEntry.Media = new Google.GData.YouTube.MediaGroup();
586
return this.YouTubeEntry.Media.Thumbnails;
593
/// returns the collection of thumbnails for the vido
595
/// <returns></returns>
596
public ExtensionCollection<Google.GData.YouTube.MediaContent> Contents
600
if (this.YouTubeEntry != null)
602
if (this.YouTubeEntry.Media == null)
604
this.YouTubeEntry.Media = new Google.GData.YouTube.MediaGroup();
606
return this.YouTubeEntry.Media.Contents;
613
/// specifies a URL where the full-length video is available through a media player that runs
614
/// inside a web browser. In a YouTube Data API response, this specifies the URL for the page
615
/// on YouTube's website that plays the video
617
/// <returns></returns>
622
if (this.YouTubeEntry!= null &&
623
this.YouTubeEntry.Media != null &&
624
this.YouTubeEntry.Media.Player != null )
626
return new Uri(this.YouTubeEntry.Media.Player.Url);
633
/// identifies the owner of a video.
635
/// <returns></returns>
636
public string Uploader
640
if (this.YouTubeEntry!= null &&
641
this.YouTubeEntry.Media != null &&
642
this.YouTubeEntry.Media.Credit != null )
644
return this.YouTubeEntry.Media.Credit.Value;
651
if (this.YouTubeEntry.Media == null)
653
this.YouTubeEntry.Media = new Google.GData.YouTube.MediaGroup();
655
if (this.YouTubeEntry.Media.Credit == null)
657
this.YouTubeEntry.Media.Credit = new Google.GData.YouTube.MediaCredit();
659
this.YouTubeEntry.Media.Credit.Value = value;
665
/// access to the Media group subelement
667
public Google.GData.YouTube.MediaGroup Media
671
if (this.YouTubeEntry != null)
673
return this.YouTubeEntry.Media;
680
this.YouTubeEntry.Media = value;
687
/// returns the viewcount for the video
689
/// <returns></returns>
694
if (this.YouTubeEntry != null && this.YouTubeEntry.Statistics != null)
695
return Int32.Parse(this.YouTubeEntry.Statistics.ViewCount);
701
/// returns the number of comments for the video
703
/// <returns></returns>
704
public int CommmentCount
708
if (this.YouTubeEntry != null &&
709
this.YouTubeEntry.Comments != null &&
710
this.YouTubeEntry.Comments.FeedLink != null)
712
return this.YouTubeEntry.Comments.FeedLink.CountHint;
719
/// returns the rating for a video
721
/// <returns></returns>
726
if (this.YouTubeEntry != null &&
727
this.YouTubeEntry.Rating != null)
729
return this.YouTubeEntry.Rating.Value;
737
if (this.YouTubeEntry.Rating == null)
739
this.YouTubeEntry.Rating = new Rating();
741
this.YouTubeEntry.Rating.Value= (int) value;
746
/// returns the average rating for a video
748
/// <returns></returns>
749
public double RatingAverage
753
if (this.YouTubeEntry != null &&
754
this.YouTubeEntry.Rating != null)
756
return this.YouTubeEntry.Rating.Average;
764
/// returns the ratings Uri, to post a rating to.
766
public Uri RatingsUri
771
if (this.YouTubeEntry != null)
773
AtomUri r = this.YouTubeEntry.RatingsLink;
775
ratings = new Uri(r.ToString());
782
/// returns the response Uri, to post a video response to.
784
public Uri ResponseUri
789
if (this.YouTubeEntry != null)
791
AtomUri r = this.YouTubeEntry.VideoResponsesUri.ToString();
793
response = new Uri(r.ToString());
800
/// returns the complaint Uri, to post a comlaint to.
802
public Uri ComplaintUri
807
if (this.YouTubeEntry != null)
809
AtomUri r = this.YouTubeEntry.ComplaintUri;
811
uri = new Uri(r.ToString());
820
/// The yt:state tag contains information that describes the status of a video.
821
/// Video entries that contain a yt:state tag are not playable.
822
/// For videos that failed to upload or were rejected after the upload process, the reasonCode
823
/// attribute and the tag value provide insight into the reason for the upload problem.
824
/// Deleted entries only appear in playlist and inbox feeds and are only visible to the playlist
832
return this.YouTubeEntry.State;
839
/// subclass of a video to represent a video that is part of a playlist
841
public class PlayListMember : Video
844
/// creates the inner contact object when needed
846
/// <returns></returns>
847
protected override void EnsureInnerObject()
849
if (this.AtomEntry == null)
851
this.AtomEntry = new PlaylistEntry();
857
/// readonly accessor for the YouTubeEntry that is underneath this object.
859
/// <returns></returns>
860
public PlaylistEntry PlaylistEntry
864
return this.AtomEntry as PlaylistEntry;
869
/// if the video is a playlist reference, get's and set's it's position in the playlist
875
if (this.PlaylistEntry != null)
876
return this.PlaylistEntry.Position;
882
this.PlaylistEntry.Position = value;
889
/// YouTube specific class for request settings,
890
/// adds support for developer key and clientid
892
/// <returns></returns>
893
public class YouTubeRequestSettings : RequestSettings
895
private string clientID;
896
private string developerKey;
899
/// A constructor for a readonly scenario.
901
/// <param name="applicationName">The name of the application</param>
902
/// <param name="client">the client ID to use</param>
903
/// <param name="developerKey">the developer key to use</param>
904
/// <returns></returns>
905
public YouTubeRequestSettings(string applicationName, string client, string developerKey) : base(applicationName)
907
this.clientID = client;
908
this.developerKey = developerKey;
912
/// A constructor for a client login scenario
914
/// <param name="applicationName">The name of the application</param>
915
/// <param name="client">the client ID to use</param>
916
/// <param name="developerKey">the developer key to use</param>
917
/// <param name="userName">the username</param>
918
/// <param name="passWord">the password</param>
919
/// <returns></returns>
920
public YouTubeRequestSettings(string applicationName, string client, string developerKey, string userName, string passWord)
921
: base(applicationName, userName, passWord)
923
this.clientID = client;
924
this.developerKey = developerKey;
928
/// a constructor for a web application authentication scenario
930
/// <param name="applicationName">The name of the application</param>
931
/// <param name="client">the client ID to use</param>
932
/// <param name="developerKey">the developer key to use</param>
933
/// <param name="authSubToken">the authentication token</param>
934
/// <returns></returns>
935
public YouTubeRequestSettings(string applicationName, string client, string developerKey, string authSubToken)
936
: base(applicationName, authSubToken)
938
this.clientID = client;
939
this.developerKey = developerKey;
943
/// returns the client ID
945
/// <returns></returns>
950
return this.clientID;
955
/// returns the developer key
957
/// <returns></returns>
958
public string DeveloperKey
962
return this.developerKey;
970
//////////////////////////////////////////////////////////////////////
972
/// The YouTube Data API allows applications to perform functions normally
973
/// executed on the YouTube website. The API enables your application to search
974
/// for YouTube videos and to retrieve standard video feeds, comments and video
976
/// In addition, the API lets your application upload videos to YouTube or
977
/// update existing videos. Your can also retrieve playlists, subscriptions,
978
/// user profiles and more. Finally, your application can submit
979
/// authenticated requests to enable users to create playlists,
980
/// subscriptions, contacts and other account-specific entities.
983
/// The following code illustrates a possible use of
984
/// the <c>YouTubeRequest</c> object:
986
/// YouTubeRequestSettings settings = new YouTubeRequestSettings("yourApp", "yourClient", "yourKey");
987
/// settings.PageSize = 50;
988
/// settings.AutoPaging = true;
989
/// YouTubeRequest f = new YouTubeRequest(settings);
990
/// Feed<Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular);
992
/// foreach (Video v in feed.Entries)
994
/// Feed<Comment> list= f.GetComments(v);
995
/// foreach (Comment c in list.Entries)
997
/// Console.WriteLine(c.Title);
1002
//////////////////////////////////////////////////////////////////////
1003
public class YouTubeRequest : FeedRequest<YouTubeService>
1007
/// default constructor for a YouTubeRequest
1009
/// <param name="settings"></param>
1010
public YouTubeRequest(YouTubeRequestSettings settings) : base(settings)
1012
if (settings.Client != null && settings.DeveloperKey != null)
1014
this.Service = new YouTubeService(settings.Application, settings.Client, settings.DeveloperKey);
1018
this.Service = new YouTubeService(settings.Application);
1025
/// returns a Feed of vidoes for a given username
1027
/// <param name="user">the username</param>
1028
/// <returns>a feed of Videos</returns>
1029
public Feed<Video> GetVideoFeed(string user)
1031
YouTubeQuery q = PrepareQuery<YouTubeQuery>(YouTubeQuery.CreateUserUri(user));
1032
return PrepareFeed<Video>(q);
1036
/// returns one of the youtube default feeds.
1038
/// <param name="feedspec">the string representation of the URI to use</param>
1039
/// <returns>a feed of Videos</returns>
1040
public Feed<Video> GetStandardFeed(string feedspec)
1042
YouTubeQuery q = PrepareQuery<YouTubeQuery>(feedspec);
1043
return PrepareFeed<Video>(q);
1047
/// returns a Feed of favorite videos for a given username
1049
/// <param name="user">the username</param>
1050
/// <returns>a feed of Videos</returns>
1051
public Feed<Video> GetFavoriteFeed(string user)
1053
YouTubeQuery q = PrepareQuery<YouTubeQuery>(YouTubeQuery.CreateFavoritesUri(user));
1054
return PrepareFeed<Video>(q);
1058
/// returns a Feed of subscriptions for a given username
1060
/// <param name="user">the username</param>
1061
/// <returns>a feed of Videos</returns>
1062
public Feed<Subscription> GetSubscriptionsFeed(string user)
1064
YouTubeQuery q = PrepareQuery<YouTubeQuery>(YouTubeQuery.CreateSubscriptionUri(user));
1065
return PrepareFeed<Subscription>(q);
1069
/// returns a Feed of playlists for a given username
1071
/// <param name="user">the username</param>
1072
/// <returns>a feed of Videos</returns>
1073
public Feed<Playlist> GetPlaylistsFeed(string user)
1075
YouTubeQuery q = PrepareQuery<YouTubeQuery>(YouTubeQuery.CreatePlaylistsUri(user));
1076
return PrepareFeed<Playlist>(q);
1080
/// returns the related videos for a given video
1082
/// <param name="v"></param>
1083
/// <returns></returns>
1084
public Feed<Video> GetRelatedVideos(Video v)
1086
if (v.YouTubeEntry != null)
1088
if (v.YouTubeEntry.RelatedVideosUri != null)
1090
YouTubeQuery q = PrepareQuery<YouTubeQuery>(v.YouTubeEntry.RelatedVideosUri.ToString());
1091
return PrepareFeed<Video>(q);
1098
/// gets the response videos for a given video
1100
/// <param name="v"></param>
1101
/// <returns></returns>
1102
public Feed<Video> GetResponseVideos(Video v)
1104
if (v.YouTubeEntry != null)
1106
if (v.YouTubeEntry.VideoResponsesUri != null)
1108
YouTubeQuery q = PrepareQuery<YouTubeQuery>(v.YouTubeEntry.VideoResponsesUri.ToString());
1109
return PrepareFeed<Video>(q);
1116
/// get's the comments for a given video
1118
/// <param name="v"></param>
1119
/// <returns></returns>
1120
public Feed<Comment> GetComments(Video v)
1122
if (v.YouTubeEntry != null &&
1123
v.YouTubeEntry.Comments != null &&
1124
v.YouTubeEntry.Comments.FeedLink != null &&
1125
v.YouTubeEntry.Comments.FeedLink.Href != null
1128
YouTubeQuery q = PrepareQuery<YouTubeQuery>(v.YouTubeEntry.Comments.FeedLink.Href);
1129
return PrepareFeed<Comment>(q);
1131
return new Feed<Comment>(null);
1136
/// get's the activities that your contacts/friends did recently
1138
/// <returns></returns>
1139
public Feed<Activity> GetActivities()
1141
return GetActivities(DateTime.MinValue);
1146
/// get's the activities for the set of users you pass in
1148
/// <param name="youTubeUsers">The list of youtube user ids to use</param>
1149
/// <returns></returns>
1150
public Feed<Activity> GetActivities(List<string> youTubeUsers)
1152
return GetActivities(youTubeUsers, DateTime.MinValue);
1156
/// get's the activities for the set of users you pass in
1158
/// <param name="youTubeUsers">The list of youtube user ids to use</param>
1159
/// <returns></returns>
1160
public Feed<Activity> GetActivities(List<string> youTubeUsers, DateTime since)
1162
if (this.Settings != null)
1164
UserActivitiesQuery q = new UserActivitiesQuery();
1165
q.ModifiedSince = since;
1166
q.Authors = youTubeUsers;
1168
return PrepareFeed<Activity>(q);
1170
return new Feed<Activity>(null);
1174
/// get's the activities that your contacts/friends did recently, from the
1175
/// given datetime point
1177
/// <returns></returns>
1178
public Feed<Activity> GetActivities(DateTime since)
1180
if (this.Settings != null)
1182
ActivitiesQuery q = new ActivitiesQuery();
1183
q.ModifiedSince = since;
1185
return PrepareFeed<Activity>(q);
1187
return new Feed<Activity>(null);
1194
returns the feed of videos for a given playlist
1197
The following code illustrates a possible use of
1198
the <c>GetPlaylist</c> method:
1200
YouTubeRequestSettings settings = new YouTubeRequestSettings("yourApp", "yourClient", "yourKey", "username", "pwd");
1201
YouTubeRequest f = new YouTubeRequest(settings);
1202
Feed<Playlist> feed = f.GetPlaylistsFeed(null);
1205
<param name="p">the playlist to get the videos for</param>
1208
public Feed<PlayListMember> GetPlaylist(Playlist p)
1210
if (p.AtomEntry != null &&
1211
p.AtomEntry.Content != null &&
1212
p.AtomEntry.Content.AbsoluteUri != null)
1214
YouTubeQuery q = PrepareQuery<YouTubeQuery>(p.AtomEntry.Content.AbsoluteUri);
1215
return PrepareFeed<PlayListMember>(q);
1217
return new Feed<PlayListMember>(null);
1222
/// uploads or inserts a new video for the default authenticated user.
1224
/// <param name="v">the created video to be used</param>
1225
/// <returns></returns>
1226
public Video Upload(Video v)
1228
return Upload(null, v);
1232
/// uploads or inserts a new video for a given user.
1234
/// <param name="userName">if this is null the default authenticated user will be used</param>
1235
/// <param name="v">the created video to be used</param>
1236
/// <returns></returns>
1237
public Video Upload(string userName, Video v)
1240
YouTubeEntry e = this.Service.Upload(userName, v.YouTubeEntry);
1250
/// creates the form upload token for the passed in video
1252
/// <param name="v">the created video to be used</param>
1253
/// <returns></returns>
1254
public FormUploadToken CreateFormUploadToken(Video v)
1256
if (v.YouTubeEntry.MediaSource != null)
1258
throw new ArgumentException("The Video should not have a media file attached to it");
1260
return this.Service.FormUpload(v.YouTubeEntry);
1267
/// returns the video this activity was related to
1269
/// <param name="activity"></param>
1270
/// <returns></returns>
1271
public Video GetVideoForActivity(Activity activity)
1275
if (activity.ActivityEntry != null)
1277
AtomUri address = activity.ActivityEntry.VideoLink;
1278
YouTubeQuery q = PrepareQuery<YouTubeQuery>(address.ToString());
1279
YouTubeFeed f = this.Service.Query(q);
1281
if (f != null && f.Entries.Count > 0)
1284
rv.AtomEntry = f.Entries[0];
1293
/// adds a comment to a video
1295
/// <param name="v">the video you want to comment on</param>
1296
/// <param name="c">the comment you want to post</param>
1297
/// <returns></returns>
1298
public Comment AddComment(Video v, Comment c)
1302
if (v.YouTubeEntry != null &&
1303
v.YouTubeEntry.Comments != null &&
1304
v.YouTubeEntry.Comments.FeedLink != null)
1306
Uri target = new Uri(v.YouTubeEntry.Comments.FeedLink.Href);
1308
rc.AtomEntry = this.Service.Insert(target, c.AtomEntry);
1316
/// adds a video to an existing playlist
1318
/// <param name="m">the new playlistmember</param>
1319
/// <param name="p">the playlist to add tot</param>
1320
/// <returns></returns>
1321
public PlayListMember AddToPlaylist( Playlist p, PlayListMember m)
1323
PlayListMember newMember = null;
1325
if (p.PlaylistsEntry!= null &&
1326
p.PlaylistsEntry.Content != null &&
1327
p.PlaylistsEntry.Content.Src != null)
1329
Uri target = new Uri(p.PlaylistsEntry.Content.Src.Content);
1330
newMember = new PlayListMember();
1331
newMember.AtomEntry = this.Service.Insert(target, m.AtomEntry);
1338
/// Takes a list of activities, and get's the video meta data from youtube
1339
/// for those activites that identify a video
1341
/// <param name="list">a list of activities</param>
1342
/// <returns>a video feed, with no entries, if there were no video related activities</returns>
1343
public Feed<Video> GetVideoMetaData(List<Activity> list)
1345
Feed<Video> meta = null;
1348
List<Video> videos = new List<Video>();
1350
foreach (Activity a in list)
1352
if (a.VideoId != null)
1354
Video v = new Video();
1355
v.Id = YouTubeQuery.CreateVideoUri(a.VideoId);
1360
if (videos.Count > 0)
1362
meta = this.Batch(videos, new Uri(YouTubeQuery.BatchVideoUri), GDataBatchOperationType.query);
1366
return meta == null? new Feed<Video>(null) : meta ;