~ubuntu-branches/ubuntu/jaunty/gnome-do-plugins/jaunty-proposed

« back to all changes in this revision

Viewing changes to BundledLibraries/libgoogle-data-mono-1.4.0.2/src/youtube/youtuberequest.cs

  • Committer: Bazaar Package Importer
  • Author(s): Iain Lane, Daniel T Chen, Iain Lane
  • Date: 2009-03-18 00:40:51 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090318004051-ujn1ja3kiu3ky7ru
Tags: 0.8.1.3+dfsg-0ubuntu1
[ Daniel T Chen ]
* New upstream release (LP: #344578)
  + Banshee plugin goes crazy if banshee isn't loaded first
    (LP: #289802)
  + gnome-do gCalculate plugin fails to display "times" symbol
    (LP: #274252)
  + Banshee-1 fails to build in Mono 2.0 (LP: #309188)
  + Pidgin 2.5.4 has incompatible dbus interface. s/uint/int/
    (LP: #314927)
  + Pidgin plugin hangs opening a chat if pidgin is unresponsive
    (LP: #315565)
  + twitter plugin still reports friend updates even when
    deactivated (LP: #317674)
  + Misspelling in microblogging plugin confirmation message
    (LP: #319433)
  + make install uses mdtool, but configure doesn't check for it
    (LP: #322951)
  + Virtualbox Icon in 2.10 are broken because of a new
    specification (LP: #323902)
  + Google Maps Plugin shouldn't always use route (LP: #324271)
  + Fix for Google Maps when using newlines and other special
    characters (LP: #324667)
  + VirtualBox failed to load icon (LP: #325712)
  + 'Read Man Pages' plugin makes Gnome-Do unresponsive
    (LP: #325935)
  + Search returns broken URLs (LP: #327855)
  + Default action for SSH hosts is "open" (LP: #328236)
  + Files and Folders Configuration doesn't use standard buttons
    (LP: #328236)
  + Window manager maximize action should focus if window is not
    currently focused (LP: #258893)
  + Locate plugin has no error message (LP: #262360)
  + Wishlist: Let user specify files and folders to ignore
    (LP: #263177)
  + ts-client plugin doesn't index subdirectories (LP: #322352)
  + Max 3000 items in Files and Folders plugin (LP: #324105)
  + putty cannot find host when running from gnome do
    (LP: #324282)
  + locate plugin with globbing (LP: #334798)
  + Twitter plugin encountered an error in UpdateFriends
    (LP: #317575)
  + gnome-terminal profiles no longer work (LP: #321977)
  + Creating a task using Remember the Milk plugin can fail if
    no task list is specified (LP: #324066)
  + bundled libraries makefile needs destdir (LP: #324704)
  + Typographical error in del.icio.us plugin (LP: #330525)
  + ImageShack fails to upload (LP: #337324)
* debian/copyright
  + Refresh for new upstream version; new plugins added.
* debian/patches/00_dfsg_autofoo.dpatch
  + Update for new upstream version
  + Don't build the YouTube plugin due to removal of shipped
    exes and dlls causing FTBFS
* debian/patches/02_ssh_respect_exec_arg.dpatch
  debian/patches/03_buildsystem_respect_mcs.dpatch
  debian/patches/04_fix_pidgin_dbus_ints.dpatch
  + Drop; fixed upstream

[ Iain Lane ]
* debian/rules: Update repackaging to not delete *.dll; upstream now ships
  source copies of google-gdata meaning we can now enable the Google and
  Youtube plugins.
* debian/patches/00_dfsg_autofoo: Drop, fixed by including and building
  these libs now. 
* debian/copyright: Update with information for google-gdata. 
* debian/patches/04_fix_pidgin_dbus_ints.dpatch: Add left out piece of patch
* debian/control: Bump gnome-do build-dep to require current version. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2006 Google Inc.
 
2
 *
 
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
 
6
 *
 
7
 *     http://www.apache.org/licenses/LICENSE-2.0
 
8
 *
 
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.
 
14
*/
 
15
 
 
16
 
 
17
using System;
 
18
using System.IO;
 
19
using System.Collections;
 
20
using System.Text;
 
21
using System.Net; 
 
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;
 
27
 
 
28
namespace Google.YouTube 
 
29
{
 
30
    public class Complaint : Entry
 
31
    {
 
32
        /// <summary>
 
33
        /// creates the inner contact object when needed
 
34
        /// </summary>
 
35
        /// <returns></returns>
 
36
        protected override void EnsureInnerObject()
 
37
        {
 
38
            if (this.AtomEntry == null)
 
39
            {
 
40
                this.AtomEntry = new ComplaintEntry();
 
41
            }
 
42
        }
 
43
        /// <summary>
 
44
        /// readonly accessor to the typed underlying atom object
 
45
        /// </summary>
 
46
        public ComplaintEntry ComplaintEntry
 
47
        {
 
48
            get
 
49
            {
 
50
                return this.AtomEntry as ComplaintEntry;
 
51
            }
 
52
        }
 
53
 
 
54
        /// <summary>
 
55
        /// set's the type of the complaint
 
56
        /// </summary>
 
57
        public ComplaintEntry.ComplaintType Type
 
58
        {
 
59
            get
 
60
            {
 
61
                if (this.ComplaintEntry != null)
 
62
                {
 
63
                    return this.ComplaintEntry.Type;
 
64
                }
 
65
                return ComplaintEntry.ComplaintType.UNKNOWN;
 
66
            }
 
67
            set
 
68
            {
 
69
                EnsureInnerObject();
 
70
                this.ComplaintEntry.Type = value;
 
71
            }
 
72
        }
 
73
 
 
74
        /// <summary>
 
75
        /// sets the verbose part of the complain, stored in the yt:content element
 
76
        /// </summary>
 
77
        public string ComplaintDescription
 
78
        {
 
79
            get
 
80
            {
 
81
                if (this.ComplaintEntry != null)
 
82
                {
 
83
                    return this.ComplaintEntry.Complaint;
 
84
                }
 
85
                return null;
 
86
            }
 
87
            set
 
88
            {
 
89
                EnsureInnerObject();
 
90
                this.ComplaintEntry.Complaint = value;
 
91
            }
 
92
        }
 
93
 
 
94
 
 
95
 
 
96
    }
 
97
 
 
98
    /// <summary>
 
99
    /// the Comment entry for a Comments Feed, a feed of Comment for YouTube
 
100
    /// </summary>
 
101
    public class Comment : Entry
 
102
    {
 
103
        /// <summary>
 
104
        /// creates the inner contact object when needed
 
105
        /// </summary>
 
106
        /// <returns></returns>
 
107
        protected override void EnsureInnerObject()
 
108
        {
 
109
            if (this.AtomEntry == null)
 
110
            {
 
111
                this.AtomEntry = new CommentEntry();
 
112
            }
 
113
        }
 
114
 
 
115
        /// <summary>
 
116
        /// readonly accessor to the underlying CommentEntry object.
 
117
        /// </summary>
 
118
        public CommentEntry CommentEntry
 
119
        {
 
120
            get
 
121
            {
 
122
                return this.AtomEntry as CommentEntry;
 
123
            }
 
124
        }
 
125
 
 
126
        /// <summary>
 
127
        /// adds the replyToLinks to this comment
 
128
        /// 
 
129
        /// </summary>
 
130
        /// <param name="c">The comment this comment is replying to</param>
 
131
        public void ReplyTo(Comment c)
 
132
        {
 
133
            if (c == null ||
 
134
                c.CommentEntry == null)
 
135
            {
 
136
                throw new ArgumentNullException("c can not be null or c.CommentEntry can not be null");
 
137
            }
 
138
            EnsureInnerObject();
 
139
            if (this.CommentEntry != null)
 
140
            {
 
141
                this.CommentEntry.ReplyTo(c.CommentEntry);
 
142
            }
 
143
        }
 
144
 
 
145
 
 
146
 
 
147
    }
 
148
 
 
149
 
 
150
    /// <summary>
 
151
    /// the subscription entry for a subscriptionfeed Feed
 
152
    /// </summary>
 
153
    public class Subscription : Entry
 
154
    {
 
155
         /// <summary>
 
156
        /// readonly accessor for the SubscriptionEntry that is underneath this object.
 
157
        /// </summary>
 
158
        /// <returns></returns>
 
159
        public  SubscriptionEntry SubscriptionEntry
 
160
        {
 
161
            get
 
162
            {
 
163
                return this.AtomEntry as SubscriptionEntry;
 
164
            }
 
165
        }
 
166
 
 
167
        
 
168
        /// <summary>
 
169
        /// creates the inner contact object when needed
 
170
        /// </summary>
 
171
        /// <returns></returns>
 
172
        protected override void EnsureInnerObject()
 
173
        {
 
174
            if (this.AtomEntry == null)
 
175
            {
 
176
                this.AtomEntry = new SubscriptionEntry();
 
177
            }
 
178
        }
 
179
 
 
180
 
 
181
 
 
182
 
 
183
        /// <summary>
 
184
        ///  returns the subscription type
 
185
        /// </summary>
 
186
        /// <returns></returns>
 
187
        public SubscriptionEntry.SubscriptionType Type
 
188
        {
 
189
            get
 
190
            {
 
191
                EnsureInnerObject();
 
192
                return this.SubscriptionEntry.Type;
 
193
            }
 
194
 
 
195
            set
 
196
            {
 
197
                EnsureInnerObject();
 
198
                this.SubscriptionEntry.Type = value;
 
199
            }
 
200
        }
 
201
 
 
202
 
 
203
        /// <summary>
 
204
        /// The user who is the owner of this subscription
 
205
        /// </summary>
 
206
        public string UserName 
 
207
        {
 
208
            get
 
209
            {
 
210
                EnsureInnerObject();
 
211
                return this.SubscriptionEntry.UserName;
 
212
            }
 
213
            set
 
214
            {
 
215
                EnsureInnerObject();
 
216
                this.SubscriptionEntry.UserName = value;
 
217
            }
 
218
        }
 
219
 
 
220
        /// <summary>
 
221
        /// if the subscripiton is a keyword query, this will be the 
 
222
        /// subscripted to query term
 
223
        /// </summary>
 
224
        public string QueryString 
 
225
        {
 
226
            get
 
227
            {
 
228
                EnsureInnerObject();
 
229
                return this.SubscriptionEntry.QueryString;
 
230
 
 
231
            }
 
232
            set
 
233
            {
 
234
                EnsureInnerObject();
 
235
                this.SubscriptionEntry.QueryString = value;
 
236
            }
 
237
        }
 
238
 
 
239
        /// <summary>
 
240
        /// the id of the playlist you are subscriped to
 
241
        /// </summary>
 
242
        public string PlaylistId 
 
243
        {
 
244
            get
 
245
            {
 
246
                EnsureInnerObject();
 
247
                return this.SubscriptionEntry.PlaylistId;
 
248
 
 
249
            }
 
250
            set
 
251
            {
 
252
                EnsureInnerObject();
 
253
                this.SubscriptionEntry.PlaylistId = value;
 
254
            }
 
255
        }
 
256
 
 
257
        /// <summary>
 
258
        /// the human readable name of the playlist you are subscribed to
 
259
        /// </summary>
 
260
        public string PlaylistTitle
 
261
        {
 
262
            get
 
263
            {
 
264
                EnsureInnerObject();
 
265
                return this.SubscriptionEntry.PlaylistTitle;
 
266
 
 
267
            }
 
268
            set
 
269
            {
 
270
                EnsureInnerObject();
 
271
                this.SubscriptionEntry.PlaylistTitle = value;
 
272
            }
 
273
        }
 
274
 
 
275
    }
 
276
 
 
277
    /// <summary>
 
278
    /// the Activity entry for an Activities Feed, a feed of activities for the friends/contacts
 
279
    /// of the logged in user
 
280
    /// </summary>
 
281
    /// <returns></returns>
 
282
    public class Activity : Entry
 
283
    {
 
284
 
 
285
 
 
286
        /// <summary>
 
287
        /// creates the inner contact object when needed
 
288
        /// </summary>
 
289
        /// <returns></returns>
 
290
        protected override void EnsureInnerObject()
 
291
        {
 
292
            if (this.AtomEntry == null)
 
293
            {
 
294
                this.AtomEntry = new ActivityEntry();
 
295
            }
 
296
        }
 
297
 
 
298
        /// <summary>
 
299
        /// readonly accessor for the YouTubeEntry that is underneath this object.
 
300
        /// </summary>
 
301
        /// <returns></returns>
 
302
        public  ActivityEntry ActivityEntry
 
303
        {
 
304
            get
 
305
            {
 
306
                return this.AtomEntry as ActivityEntry;
 
307
            }
 
308
        }
 
309
 
 
310
 
 
311
        /// <summary>
 
312
        /// specifies a unique ID that YouTube uses to identify a video.
 
313
        /// </summary>
 
314
        /// <returns></returns>
 
315
        public string VideoId
 
316
        {
 
317
            get
 
318
            {
 
319
                EnsureInnerObject();
 
320
                if (this.ActivityEntry.VideoId != null)
 
321
                {
 
322
                    return this.ActivityEntry.VideoId.Value;
 
323
                }
 
324
                return null; 
 
325
            }
 
326
        }
 
327
 
 
328
        /// <summary>
 
329
        /// the type of the activity
 
330
        /// </summary>
 
331
        public ActivityType Type
 
332
        {
 
333
            get
 
334
            {
 
335
                EnsureInnerObject();
 
336
                return this.ActivityEntry.Type;
 
337
            }
 
338
        }
 
339
 
 
340
        /// <summary>
 
341
        /// the username of the friend who was added,
 
342
        /// or the user whom was subscribed to
 
343
        /// </summary>
 
344
        public string Username
 
345
        {
 
346
            get
 
347
            {
 
348
                EnsureInnerObject();
 
349
                if (this.ActivityEntry.Username != null)
 
350
                {
 
351
                    return this.ActivityEntry.Username.Value;
 
352
                }
 
353
                return null;
 
354
            }
 
355
        }
 
356
    }
 
357
 
 
358
     /// <summary>
 
359
    /// the Playlist entry for a Playlist Feed, a feed of Playlist for YouTube
 
360
    /// </summary>
 
361
    public class Playlist : Entry
 
362
    {
 
363
 
 
364
        /// <summary>
 
365
        /// creates the inner contact object when needed
 
366
        /// </summary>
 
367
        /// <returns></returns>
 
368
        protected override void EnsureInnerObject()
 
369
        {
 
370
            if (this.AtomEntry == null)
 
371
            {
 
372
                this.AtomEntry = new PlaylistsEntry();
 
373
            }
 
374
        }
 
375
 
 
376
        /// <summary>
 
377
        /// returns the internal atomentry as a PlayListsEntry
 
378
        /// </summary>
 
379
        /// <returns></returns>
 
380
        public PlaylistsEntry PlaylistsEntry
 
381
        {
 
382
            get
 
383
            {
 
384
                return this.AtomEntry as PlaylistsEntry;
 
385
            }
 
386
        }
 
387
 
 
388
        /// <summary>
 
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.
 
391
        /// </summary>
 
392
        /// <returns></returns>
 
393
        public int CountHint
 
394
        {
 
395
            get 
 
396
            {
 
397
                EnsureInnerObject();
 
398
                return this.PlaylistsEntry.CountHint;
 
399
            }
 
400
        }
 
401
    }
 
402
 
 
403
 
 
404
    //////////////////////////////////////////////////////////////////////
 
405
    /// <summary>the Video Entry in feed&lt;Videos&gt; for YouTube
 
406
    /// </summary> 
 
407
    //////////////////////////////////////////////////////////////////////
 
408
    public class Video : Entry
 
409
    {
 
410
        
 
411
 
 
412
        /// <summary>
 
413
        /// creates the inner contact object when needed
 
414
        /// </summary>
 
415
        /// <returns></returns>
 
416
        protected override void EnsureInnerObject()
 
417
        {
 
418
            if (this.AtomEntry == null)
 
419
            {
 
420
                this.AtomEntry = new YouTubeEntry();
 
421
            }
 
422
        }
 
423
 
 
424
 
 
425
        /// <summary>
 
426
        /// readonly accessor for the YouTubeEntry that is underneath this object.
 
427
        /// </summary>
 
428
        /// <returns></returns>
 
429
        public  YouTubeEntry YouTubeEntry
 
430
        {
 
431
            get
 
432
            {
 
433
                return this.AtomEntry as YouTubeEntry;
 
434
            }
 
435
        }
 
436
 
 
437
        /// <summary>
 
438
        /// specifies a unique ID that YouTube uses to identify a video.
 
439
        /// </summary>
 
440
        /// <returns></returns>
 
441
        public string VideoId
 
442
        {
 
443
            get
 
444
            {
 
445
                EnsureInnerObject();
 
446
                return this.YouTubeEntry.VideoId;
 
447
            }
 
448
            set
 
449
            {
 
450
                EnsureInnerObject();
 
451
                this.YouTubeEntry.VideoId = value;
 
452
            }
 
453
 
 
454
        }
 
455
 
 
456
        /// <summary>
 
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 &lt; and &gt; 
 
461
        /// </summary>
 
462
        /// <returns></returns>
 
463
        public string Description
 
464
        {
 
465
            get
 
466
            {
 
467
                if (this.YouTubeEntry != null && 
 
468
                    this.YouTubeEntry.Media != null &&
 
469
                    this.YouTubeEntry.Media.Description != null)
 
470
                {
 
471
                    return this.YouTubeEntry.Media.Description.Value;
 
472
                }
 
473
                return null; 
 
474
            }
 
475
            set
 
476
            {
 
477
                EnsureInnerObject();
 
478
                if (this.YouTubeEntry.Media == null)
 
479
                {
 
480
                    this.YouTubeEntry.Media = new Google.GData.YouTube.MediaGroup();
 
481
                }
 
482
                if (this.YouTubeEntry.Media.Description == null)
 
483
                {
 
484
                    this.YouTubeEntry.Media.Description = new MediaDescription();
 
485
                }
 
486
                this.YouTubeEntry.Media.Description.Value = value; 
 
487
            }
 
488
        }
 
489
 
 
490
 
 
491
        /// <summary>
 
492
        /// the title of the Video. Overloaded to keep entry.title and the media.title 
 
493
        ///  in sync. 
 
494
        /// </summary>
 
495
        /// <returns></returns>
 
496
        public override string Title
 
497
        {
 
498
            get
 
499
            {
 
500
                return base.Title;
 
501
            }
 
502
            set
 
503
            {
 
504
                base.Title = value;
 
505
                EnsureInnerObject();
 
506
                if (this.YouTubeEntry.Media == null)
 
507
                {
 
508
                    this.YouTubeEntry.Media = new Google.GData.YouTube.MediaGroup();
 
509
                }
 
510
                if (this.YouTubeEntry.Media.Title == null)
 
511
                {
 
512
                    this.YouTubeEntry.Media.Title = new MediaTitle();
 
513
                }
 
514
                this.YouTubeEntry.Media.Title.Value = value; 
 
515
            }
 
516
        }
 
517
 
 
518
 
 
519
        /// <summary>
 
520
        /// returns the categories for the video
 
521
        /// </summary>
 
522
        /// <returns></returns>
 
523
        public ExtensionCollection<MediaCategory> Tags
 
524
        {
 
525
            get
 
526
            {
 
527
                EnsureInnerObject();
 
528
                if (this.YouTubeEntry.Media == null)
 
529
                {
 
530
                    this.YouTubeEntry.Media = new Google.GData.YouTube.MediaGroup();
 
531
                }
 
532
                return this.YouTubeEntry.Media.Categories; 
 
533
            }
 
534
        }
 
535
 
 
536
        /// <summary>
 
537
        /// returns the keywords for the video, see MediaKeywords for more
 
538
        /// </summary>
 
539
        /// <returns></returns>
 
540
        public string Keywords
 
541
        {
 
542
            get
 
543
            {
 
544
                if (this.YouTubeEntry != null)
 
545
                {
 
546
                    if (this.YouTubeEntry.Media != null)
 
547
                    {
 
548
                        if (this.YouTubeEntry.Media.Keywords != null)
 
549
                        {
 
550
                            return this.YouTubeEntry.Media.Keywords.Value;
 
551
                        }
 
552
                    }
 
553
                }
 
554
                return null;
 
555
            }
 
556
            set
 
557
            {
 
558
                EnsureInnerObject();
 
559
                if (this.YouTubeEntry.Media == null)
 
560
                {
 
561
                    this.YouTubeEntry.Media = new Google.GData.YouTube.MediaGroup();
 
562
                }
 
563
                if (this.YouTubeEntry.Media.Keywords == null)
 
564
                {
 
565
                    this.YouTubeEntry.Media.Keywords = new MediaKeywords();
 
566
                }
 
567
                this.YouTubeEntry.Media.Keywords.Value = value; 
 
568
            }
 
569
        }
 
570
 
 
571
 
 
572
        /// <summary>
 
573
        /// returns the collection of thumbnails for the vido
 
574
        /// </summary>
 
575
        /// <returns></returns>
 
576
        public ExtensionCollection<MediaThumbnail> Thumbnails
 
577
        {
 
578
            get
 
579
            {
 
580
                if (this.YouTubeEntry != null)
 
581
                {
 
582
                    if (this.YouTubeEntry.Media == null)
 
583
                    {
 
584
                        this.YouTubeEntry.Media = new Google.GData.YouTube.MediaGroup();
 
585
                    }
 
586
                    return this.YouTubeEntry.Media.Thumbnails; 
 
587
                }
 
588
                return null;
 
589
            }
 
590
        }
 
591
 
 
592
        /// <summary>
 
593
        /// returns the collection of thumbnails for the vido
 
594
        /// </summary>
 
595
        /// <returns></returns>
 
596
        public ExtensionCollection<Google.GData.YouTube.MediaContent> Contents
 
597
        {
 
598
            get
 
599
            {
 
600
                if (this.YouTubeEntry != null)
 
601
                {
 
602
                    if (this.YouTubeEntry.Media == null)
 
603
                    {
 
604
                        this.YouTubeEntry.Media = new Google.GData.YouTube.MediaGroup();
 
605
                    }
 
606
                    return this.YouTubeEntry.Media.Contents;
 
607
                }
 
608
                return null;
 
609
            }
 
610
        }
 
611
 
 
612
        /// <summary>
 
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
 
616
        /// </summary>
 
617
        /// <returns></returns>
 
618
        public Uri WatchPage
 
619
        {
 
620
            get
 
621
            {
 
622
                if (this.YouTubeEntry!= null  && 
 
623
                    this.YouTubeEntry.Media != null  && 
 
624
                    this.YouTubeEntry.Media.Player != null )
 
625
                {
 
626
                    return new Uri(this.YouTubeEntry.Media.Player.Url);
 
627
                }
 
628
                return null; 
 
629
            }
 
630
        }
 
631
 
 
632
        /// <summary>
 
633
        /// identifies the owner of a video.
 
634
        /// </summary>
 
635
        /// <returns></returns>
 
636
        public string Uploader
 
637
        {
 
638
            get
 
639
            {
 
640
                if (this.YouTubeEntry!= null  && 
 
641
                    this.YouTubeEntry.Media != null  && 
 
642
                    this.YouTubeEntry.Media.Credit != null )
 
643
                {
 
644
                    return this.YouTubeEntry.Media.Credit.Value;
 
645
                }
 
646
                return null; 
 
647
            }
 
648
            set
 
649
            {
 
650
                EnsureInnerObject();
 
651
                if (this.YouTubeEntry.Media == null)
 
652
                {
 
653
                    this.YouTubeEntry.Media = new Google.GData.YouTube.MediaGroup();
 
654
                }
 
655
                if (this.YouTubeEntry.Media.Credit == null)
 
656
                {
 
657
                    this.YouTubeEntry.Media.Credit = new Google.GData.YouTube.MediaCredit();
 
658
                }
 
659
                this.YouTubeEntry.Media.Credit.Value = value; 
 
660
            }
 
661
        }
 
662
 
 
663
 
 
664
        /// <summary>
 
665
        /// access to the Media group subelement
 
666
        /// </summary>
 
667
        public Google.GData.YouTube.MediaGroup Media
 
668
        {
 
669
            get
 
670
            {
 
671
                if (this.YouTubeEntry != null)
 
672
                {                    
 
673
                    return this.YouTubeEntry.Media; 
 
674
                }
 
675
                return null;
 
676
            }
 
677
            set
 
678
            {
 
679
                EnsureInnerObject();
 
680
                this.YouTubeEntry.Media = value; 
 
681
            }
 
682
        }
 
683
 
 
684
 
 
685
 
 
686
        /// <summary>
 
687
        /// returns the viewcount for the video
 
688
        /// </summary>
 
689
        /// <returns></returns>
 
690
        public int ViewCount
 
691
        {
 
692
            get
 
693
            {
 
694
                if (this.YouTubeEntry != null && this.YouTubeEntry.Statistics != null)
 
695
                    return Int32.Parse(this.YouTubeEntry.Statistics.ViewCount);
 
696
                return -1;
 
697
            }
 
698
        }
 
699
 
 
700
        /// <summary>
 
701
        /// returns the number of comments for the video
 
702
        /// </summary>
 
703
        /// <returns></returns>
 
704
        public int CommmentCount
 
705
        {
 
706
            get
 
707
            {
 
708
                if (this.YouTubeEntry != null && 
 
709
                    this.YouTubeEntry.Comments != null &&
 
710
                    this.YouTubeEntry.Comments.FeedLink != null)
 
711
                {
 
712
                        return this.YouTubeEntry.Comments.FeedLink.CountHint;
 
713
                }
 
714
                return -1;
 
715
            }
 
716
        }
 
717
 
 
718
        /// <summary>
 
719
        /// returns the rating for a video
 
720
        /// </summary>
 
721
        /// <returns></returns>
 
722
        public int Rating
 
723
        {
 
724
            get
 
725
            {
 
726
                if (this.YouTubeEntry != null &&
 
727
                    this.YouTubeEntry.Rating != null)
 
728
                {
 
729
                    return this.YouTubeEntry.Rating.Value;
 
730
                }
 
731
                return -1;
 
732
            }
 
733
 
 
734
            set
 
735
            {
 
736
                EnsureInnerObject();
 
737
                if (this.YouTubeEntry.Rating == null)
 
738
                {
 
739
                    this.YouTubeEntry.Rating = new Rating();
 
740
                }
 
741
                this.YouTubeEntry.Rating.Value= (int) value;
 
742
            }
 
743
        }
 
744
 
 
745
        /// <summary>
 
746
        /// returns the average rating for a video
 
747
        /// </summary>
 
748
        /// <returns></returns>
 
749
        public double RatingAverage
 
750
        {
 
751
            get
 
752
            {
 
753
                if (this.YouTubeEntry != null &&
 
754
                    this.YouTubeEntry.Rating != null)
 
755
                {
 
756
                    return this.YouTubeEntry.Rating.Average;
 
757
                }
 
758
                return -1;
 
759
            }
 
760
        }
 
761
 
 
762
 
 
763
        /// <summary>
 
764
        /// returns the ratings Uri, to post a rating to.
 
765
        /// </summary>
 
766
        public Uri RatingsUri
 
767
        {
 
768
            get
 
769
            {
 
770
                Uri ratings = null; 
 
771
                if (this.YouTubeEntry != null)
 
772
                {
 
773
                    AtomUri r = this.YouTubeEntry.RatingsLink;
 
774
                    if (r != null)
 
775
                        ratings = new Uri(r.ToString());
 
776
                }
 
777
                return ratings; 
 
778
            }
 
779
        }
 
780
 
 
781
        /// <summary>
 
782
        /// returns the response Uri, to post a video response to.
 
783
        /// </summary>
 
784
        public Uri ResponseUri
 
785
        {
 
786
            get
 
787
            {
 
788
                Uri response = null;
 
789
                if (this.YouTubeEntry != null)
 
790
                {
 
791
                    AtomUri r = this.YouTubeEntry.VideoResponsesUri.ToString();
 
792
                    if (r != null)
 
793
                        response = new Uri(r.ToString());
 
794
                }
 
795
                return response;
 
796
            }
 
797
        }
 
798
 
 
799
        /// <summary>
 
800
        /// returns the complaint Uri, to post a comlaint to.
 
801
        /// </summary>
 
802
        public Uri ComplaintUri
 
803
        {
 
804
            get
 
805
            {
 
806
                Uri uri = null;
 
807
                if (this.YouTubeEntry != null)
 
808
                {
 
809
                    AtomUri r = this.YouTubeEntry.ComplaintUri;
 
810
                    if (r != null)
 
811
                        uri = new Uri(r.ToString());
 
812
                }
 
813
                return uri;
 
814
            }
 
815
        }
 
816
 
 
817
 
 
818
 
 
819
        /// <summary>
 
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 
 
825
        /// or inbox owner.
 
826
        /// </summary>
 
827
        public State Status
 
828
        {
 
829
            get
 
830
            {
 
831
                EnsureInnerObject();
 
832
                return this.YouTubeEntry.State;
 
833
            }
 
834
        }
 
835
    }
 
836
 
 
837
 
 
838
    /// <summary>
 
839
    /// subclass of a video to represent a video that is part of a playlist
 
840
    /// </summary>
 
841
    public class PlayListMember : Video
 
842
    {
 
843
        /// <summary>
 
844
        /// creates the inner contact object when needed
 
845
        /// </summary>
 
846
        /// <returns></returns>
 
847
        protected override void EnsureInnerObject()
 
848
        {
 
849
            if (this.AtomEntry == null)
 
850
            {
 
851
                this.AtomEntry = new PlaylistEntry();
 
852
            }
 
853
        }
 
854
 
 
855
 
 
856
        /// <summary>
 
857
        /// readonly accessor for the YouTubeEntry that is underneath this object.
 
858
        /// </summary>
 
859
        /// <returns></returns>
 
860
        public  PlaylistEntry PlaylistEntry
 
861
        {
 
862
            get
 
863
            {
 
864
                return this.AtomEntry as PlaylistEntry;
 
865
            }
 
866
        }
 
867
 
 
868
         /// <summary>
 
869
        /// if the video is a playlist reference, get's and set's it's position in the playlist
 
870
        /// </summary>
 
871
        public int Position
 
872
        {
 
873
            get
 
874
            {
 
875
                if (this.PlaylistEntry != null)
 
876
                    return this.PlaylistEntry.Position;
 
877
                return -1;
 
878
            }
 
879
            set
 
880
            {
 
881
                EnsureInnerObject();
 
882
                this.PlaylistEntry.Position = value;
 
883
            }
 
884
        }
 
885
    }
 
886
 
 
887
 
 
888
    /// <summary>
 
889
    /// YouTube specific class for request settings,
 
890
    /// adds support for developer key and clientid
 
891
    /// </summary>
 
892
    /// <returns></returns>
 
893
    public class YouTubeRequestSettings : RequestSettings
 
894
    {
 
895
        private string clientID;
 
896
        private string developerKey;
 
897
 
 
898
        /// <summary>
 
899
        /// A constructor for a readonly scenario.
 
900
        /// </summary>
 
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)
 
906
        {
 
907
            this.clientID = client;
 
908
            this.developerKey = developerKey;
 
909
        }
 
910
 
 
911
        /// <summary>
 
912
        /// A constructor for a client login scenario
 
913
        /// </summary>
 
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)
 
922
        {
 
923
            this.clientID = client;
 
924
            this.developerKey = developerKey;
 
925
        }
 
926
 
 
927
        /// <summary>
 
928
        /// a constructor for a web application authentication scenario        
 
929
        /// </summary>
 
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)
 
937
        {
 
938
            this.clientID = client;
 
939
            this.developerKey = developerKey;
 
940
        }
 
941
 
 
942
        /// <summary>
 
943
        /// returns the client ID
 
944
        /// </summary>
 
945
        /// <returns></returns>
 
946
        public string Client
 
947
        {
 
948
            get
 
949
            {
 
950
                return this.clientID;
 
951
            }
 
952
        }
 
953
 
 
954
        /// <summary>
 
955
        /// returns the developer key
 
956
        /// </summary>
 
957
        /// <returns></returns>
 
958
        public string DeveloperKey
 
959
        {
 
960
            get
 
961
            {
 
962
                return this.developerKey;
 
963
            }
 
964
        }
 
965
    }
 
966
 
 
967
 
 
968
 
 
969
 
 
970
    //////////////////////////////////////////////////////////////////////
 
971
    /// <summary>
 
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
 
975
    /// responses. 
 
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.
 
981
    /// </summary>
 
982
    ///  <example>
 
983
    ///         The following code illustrates a possible use of   
 
984
    ///          the <c>YouTubeRequest</c> object:  
 
985
    ///          <code>    
 
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);
 
991
    ///     
 
992
    ///         foreach (Video v in feed.Entries)
 
993
    ///         {
 
994
    ///             Feed<Comment> list= f.GetComments(v);
 
995
    ///             foreach (Comment c in list.Entries)
 
996
    ///             {
 
997
    ///                 Console.WriteLine(c.Title);
 
998
    ///             }
 
999
    ///         }
 
1000
    ///  </code>
 
1001
    ///  </example>
 
1002
    //////////////////////////////////////////////////////////////////////
 
1003
    public class YouTubeRequest : FeedRequest<YouTubeService>
 
1004
    {
 
1005
 
 
1006
        /// <summary>
 
1007
        /// default constructor for a YouTubeRequest
 
1008
        /// </summary>
 
1009
        /// <param name="settings"></param>
 
1010
        public YouTubeRequest(YouTubeRequestSettings settings) : base(settings)
 
1011
        {
 
1012
            if (settings.Client != null && settings.DeveloperKey != null)
 
1013
            {
 
1014
                this.Service = new YouTubeService(settings.Application, settings.Client, settings.DeveloperKey);
 
1015
            }
 
1016
            else
 
1017
            {
 
1018
                this.Service = new YouTubeService(settings.Application);
 
1019
            }
 
1020
 
 
1021
            PrepareService();
 
1022
        }
 
1023
 
 
1024
        /// <summary>
 
1025
        /// returns a Feed of vidoes for a given username
 
1026
        /// </summary>
 
1027
        /// <param name="user">the username</param>
 
1028
        /// <returns>a feed of Videos</returns>
 
1029
        public Feed<Video> GetVideoFeed(string user)
 
1030
        {
 
1031
            YouTubeQuery q = PrepareQuery<YouTubeQuery>(YouTubeQuery.CreateUserUri(user));
 
1032
            return PrepareFeed<Video>(q); 
 
1033
        }
 
1034
 
 
1035
         /// <summary>
 
1036
        ///  returns one of the youtube default feeds. 
 
1037
        /// </summary>
 
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)
 
1041
        {
 
1042
            YouTubeQuery q = PrepareQuery<YouTubeQuery>(feedspec);
 
1043
            return PrepareFeed<Video>(q); 
 
1044
        }
 
1045
 
 
1046
        /// <summary>
 
1047
        /// returns a Feed of favorite videos for a given username
 
1048
        /// </summary>
 
1049
        /// <param name="user">the username</param>
 
1050
        /// <returns>a feed of Videos</returns>
 
1051
        public Feed<Video> GetFavoriteFeed(string user)
 
1052
        {
 
1053
            YouTubeQuery q = PrepareQuery<YouTubeQuery>(YouTubeQuery.CreateFavoritesUri(user));
 
1054
            return PrepareFeed<Video>(q); 
 
1055
        }
 
1056
 
 
1057
        /// <summary>
 
1058
        /// returns a Feed of subscriptions for a given username
 
1059
        /// </summary>
 
1060
        /// <param name="user">the username</param>
 
1061
        /// <returns>a feed of Videos</returns>
 
1062
        public Feed<Subscription> GetSubscriptionsFeed(string user)
 
1063
        {
 
1064
            YouTubeQuery q = PrepareQuery<YouTubeQuery>(YouTubeQuery.CreateSubscriptionUri(user));
 
1065
            return PrepareFeed<Subscription>(q); 
 
1066
        }
 
1067
 
 
1068
        /// <summary>
 
1069
        /// returns a Feed of playlists  for a given username
 
1070
        /// </summary>
 
1071
        /// <param name="user">the username</param>
 
1072
        /// <returns>a feed of Videos</returns>
 
1073
        public Feed<Playlist> GetPlaylistsFeed(string user)
 
1074
        {
 
1075
            YouTubeQuery q = PrepareQuery<YouTubeQuery>(YouTubeQuery.CreatePlaylistsUri(user));
 
1076
            return PrepareFeed<Playlist>(q);             
 
1077
        }
 
1078
 
 
1079
        /// <summary>
 
1080
        /// returns the related videos for a given video
 
1081
        /// </summary>
 
1082
        /// <param name="v"></param>
 
1083
        /// <returns></returns>
 
1084
        public Feed<Video> GetRelatedVideos(Video v)
 
1085
        {
 
1086
            if (v.YouTubeEntry != null)
 
1087
            {
 
1088
                if (v.YouTubeEntry.RelatedVideosUri != null)
 
1089
                {
 
1090
                    YouTubeQuery q = PrepareQuery<YouTubeQuery>(v.YouTubeEntry.RelatedVideosUri.ToString());
 
1091
                    return PrepareFeed<Video>(q); 
 
1092
                }
 
1093
            }
 
1094
            return null;
 
1095
        }
 
1096
 
 
1097
        /// <summary>
 
1098
        ///  gets the response videos for a given video
 
1099
        /// </summary>
 
1100
        /// <param name="v"></param>
 
1101
        /// <returns></returns>
 
1102
        public Feed<Video> GetResponseVideos(Video v)
 
1103
        {
 
1104
            if (v.YouTubeEntry != null)
 
1105
            {
 
1106
                if (v.YouTubeEntry.VideoResponsesUri != null)
 
1107
                {
 
1108
                    YouTubeQuery q = PrepareQuery<YouTubeQuery>(v.YouTubeEntry.VideoResponsesUri.ToString());
 
1109
                    return PrepareFeed<Video>(q); 
 
1110
                }
 
1111
            }
 
1112
            return null;
 
1113
        }
 
1114
 
 
1115
        /// <summary>
 
1116
        /// get's the comments for a given video
 
1117
        /// </summary>
 
1118
        /// <param name="v"></param>
 
1119
        /// <returns></returns>
 
1120
        public Feed<Comment> GetComments(Video v)
 
1121
        {
 
1122
             if (v.YouTubeEntry != null && 
 
1123
                    v.YouTubeEntry.Comments != null && 
 
1124
                    v.YouTubeEntry.Comments.FeedLink != null && 
 
1125
                    v.YouTubeEntry.Comments.FeedLink.Href != null
 
1126
                    )
 
1127
             {
 
1128
                    YouTubeQuery q = PrepareQuery<YouTubeQuery>(v.YouTubeEntry.Comments.FeedLink.Href);
 
1129
                    return PrepareFeed<Comment>(q); 
 
1130
             }
 
1131
             return new Feed<Comment>(null);
 
1132
        }
 
1133
 
 
1134
 
 
1135
        /// <summary>
 
1136
        /// get's the activities that your contacts/friends did recently 
 
1137
        /// </summary>
 
1138
        /// <returns></returns>
 
1139
        public Feed<Activity> GetActivities()
 
1140
        {
 
1141
            return GetActivities(DateTime.MinValue);
 
1142
        }
 
1143
 
 
1144
        
 
1145
        /// <summary>
 
1146
        /// get's the activities for the set of users you pass in
 
1147
        /// </summary>
 
1148
        /// <param name="youTubeUsers">The list of youtube user ids to use</param>
 
1149
        /// <returns></returns>
 
1150
        public Feed<Activity> GetActivities(List<string> youTubeUsers)
 
1151
        {
 
1152
            return GetActivities(youTubeUsers, DateTime.MinValue);
 
1153
        }
 
1154
 
 
1155
        /// <summary>
 
1156
        /// get's the activities for the set of users you pass in
 
1157
        /// </summary>
 
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)
 
1161
        {
 
1162
            if (this.Settings != null)
 
1163
            {
 
1164
                UserActivitiesQuery q = new UserActivitiesQuery();
 
1165
                q.ModifiedSince = since;
 
1166
                q.Authors = youTubeUsers;
 
1167
                PrepareQuery(q);
 
1168
                return PrepareFeed<Activity>(q);             
 
1169
            }
 
1170
            return new Feed<Activity>(null);
 
1171
        }
 
1172
 
 
1173
        /// <summary>
 
1174
        /// get's the activities that your contacts/friends did recently, from the 
 
1175
        /// given datetime point
 
1176
        /// </summary>
 
1177
        /// <returns></returns>
 
1178
        public Feed<Activity> GetActivities(DateTime since)
 
1179
        {
 
1180
            if (this.Settings != null)
 
1181
            {
 
1182
                ActivitiesQuery q = new ActivitiesQuery();
 
1183
                q.ModifiedSince = since; 
 
1184
                PrepareQuery(q);
 
1185
                return PrepareFeed<Activity>(q);             
 
1186
            }
 
1187
            return new Feed<Activity>(null);
 
1188
        }
 
1189
 
 
1190
 
 
1191
 
 
1192
        /** 
 
1193
           <summary>
 
1194
            returns the feed of videos for a given playlist
 
1195
           </summary>
 
1196
            <example>
 
1197
                The following code illustrates a possible use of   
 
1198
                the <c>GetPlaylist</c> method:  
 
1199
                <code>    
 
1200
                  YouTubeRequestSettings settings = new YouTubeRequestSettings("yourApp", "yourClient", "yourKey", "username", "pwd");
 
1201
                  YouTubeRequest f = new YouTubeRequest(settings);
 
1202
                  Feed&lt;Playlist&gt; feed = f.GetPlaylistsFeed(null);
 
1203
                </code>
 
1204
            </example>
 
1205
            <param name="p">the playlist to get the videos for</param>
 
1206
            <returns></returns>
 
1207
        */
 
1208
        public Feed<PlayListMember> GetPlaylist(Playlist p)
 
1209
        {
 
1210
            if (p.AtomEntry != null && 
 
1211
                p.AtomEntry.Content != null && 
 
1212
                p.AtomEntry.Content.AbsoluteUri != null)
 
1213
            {
 
1214
                   YouTubeQuery q = PrepareQuery<YouTubeQuery>(p.AtomEntry.Content.AbsoluteUri);
 
1215
                   return PrepareFeed<PlayListMember>(q); 
 
1216
            }
 
1217
            return new Feed<PlayListMember>(null);
 
1218
        }
 
1219
 
 
1220
 
 
1221
        /// <summary>
 
1222
        /// uploads or inserts a new video for the default authenticated user.
 
1223
        /// </summary>
 
1224
        /// <param name="v">the created video to be used</param>
 
1225
        /// <returns></returns>
 
1226
        public Video Upload(Video v)
 
1227
        {
 
1228
            return Upload(null, v);
 
1229
        }
 
1230
 
 
1231
        /// <summary>
 
1232
        /// uploads or inserts a new video for a given user.
 
1233
        /// </summary>
 
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)
 
1238
        {
 
1239
            Video rv = null;
 
1240
            YouTubeEntry e = this.Service.Upload(userName, v.YouTubeEntry);
 
1241
            if (e != null)
 
1242
            {
 
1243
                rv= new Video();
 
1244
                rv.AtomEntry = e; 
 
1245
            }
 
1246
            return rv; 
 
1247
        }
 
1248
 
 
1249
        /// <summary>
 
1250
        /// creates the form upload token for the passed in video
 
1251
        /// </summary>
 
1252
        /// <param name="v">the created video to be used</param>
 
1253
        /// <returns></returns>
 
1254
        public FormUploadToken CreateFormUploadToken(Video v)
 
1255
        {
 
1256
            if (v.YouTubeEntry.MediaSource != null)
 
1257
            {
 
1258
                throw new ArgumentException("The Video should not have a media file attached to it");
 
1259
            }
 
1260
            return this.Service.FormUpload(v.YouTubeEntry);
 
1261
        }
 
1262
 
 
1263
 
 
1264
 
 
1265
 
 
1266
        /// <summary>
 
1267
        /// returns the video this activity was related to
 
1268
        /// </summary>
 
1269
        /// <param name="activity"></param>
 
1270
        /// <returns></returns>
 
1271
        public Video GetVideoForActivity(Activity activity)
 
1272
        {
 
1273
            Video rv = null;
 
1274
 
 
1275
            if (activity.ActivityEntry != null)
 
1276
            {
 
1277
                AtomUri address = activity.ActivityEntry.VideoLink;
 
1278
                YouTubeQuery q = PrepareQuery<YouTubeQuery>(address.ToString());
 
1279
                YouTubeFeed f = this.Service.Query(q);
 
1280
 
 
1281
                if (f != null && f.Entries.Count > 0)
 
1282
                {
 
1283
                    rv = new Video();
 
1284
                    rv.AtomEntry = f.Entries[0];
 
1285
                }
 
1286
            }
 
1287
 
 
1288
            return rv;
 
1289
        }
 
1290
 
 
1291
 
 
1292
        /// <summary>
 
1293
        /// adds a comment to a video
 
1294
        /// </summary>
 
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)
 
1299
        {
 
1300
            Comment rc = null; 
 
1301
 
 
1302
            if (v.YouTubeEntry != null &&
 
1303
                v.YouTubeEntry.Comments != null &&
 
1304
                v.YouTubeEntry.Comments.FeedLink != null)
 
1305
            {
 
1306
                Uri target = new Uri(v.YouTubeEntry.Comments.FeedLink.Href);
 
1307
                rc = new Comment();
 
1308
                rc.AtomEntry = this.Service.Insert(target, c.AtomEntry);
 
1309
            }
 
1310
 
 
1311
 
 
1312
            return rc;
 
1313
        }
 
1314
 
 
1315
        /// <summary>
 
1316
        /// adds a video to an existing playlist
 
1317
        /// </summary>
 
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)
 
1322
        {
 
1323
            PlayListMember newMember = null;
 
1324
 
 
1325
            if (p.PlaylistsEntry!= null &&
 
1326
                p.PlaylistsEntry.Content != null &&
 
1327
                p.PlaylistsEntry.Content.Src != null)
 
1328
            {
 
1329
                Uri target = new Uri(p.PlaylistsEntry.Content.Src.Content);
 
1330
                newMember = new PlayListMember();
 
1331
                newMember.AtomEntry = this.Service.Insert(target, m.AtomEntry);
 
1332
            }
 
1333
            return newMember;
 
1334
        }
 
1335
 
 
1336
 
 
1337
        /// <summary>
 
1338
        /// Takes a list of activities, and get's the video meta data from youtube 
 
1339
        /// for those activites that identify a video
 
1340
        /// </summary>
 
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)
 
1344
        {
 
1345
            Feed<Video> meta = null;
 
1346
            if (list.Count > 0)
 
1347
            {
 
1348
                List<Video> videos = new List<Video>();
 
1349
 
 
1350
                foreach (Activity a in list)
 
1351
                {
 
1352
                    if (a.VideoId != null)
 
1353
                    {
 
1354
                        Video v = new Video();
 
1355
                        v.Id = YouTubeQuery.CreateVideoUri(a.VideoId);
 
1356
                        videos.Add(v);
 
1357
                    }
 
1358
                }
 
1359
 
 
1360
                if (videos.Count > 0)
 
1361
                {
 
1362
                    meta = this.Batch(videos, new Uri(YouTubeQuery.BatchVideoUri), GDataBatchOperationType.query);
 
1363
                }
 
1364
            }
 
1365
 
 
1366
            return meta == null? new Feed<Video>(null) : meta ; 
 
1367
        }
 
1368
    }
 
1369
}