public static YoutubeVideo FromSingleVideo(string uri)
    {
      var uriConverter = new UriConverter(new WebClientImpl());
      var videoId = uriConverter.GetVideoId(uri);
      var gdataUri = uriConverter.FromYoutubeVideoToGDataVideo(videoId);

      var webClient = new WebClientImpl();
      var responseXml = webClient.DownloadString(gdataUri);

      var responseDocument = XDocument.Parse(responseXml, LoadOptions.SetBaseUri);

      XNamespace atom = "http://www.w3.org/2005/Atom";
      var titleElement = responseDocument.Root.Element(atom + "title");
      var videoTitle = titleElement != null ? titleElement.Value : string.Empty;

      var flvUri = uriConverter.GetFlvUriFromYoutubeVideoUri(videoId);

      return string.IsNullOrEmpty(flvUri) ?
        null : new YoutubeVideo
         {
           FlvUri = flvUri,
           Link = uri,
           Title = videoTitle
         };
    }
    public void GetVideoId_WithSingleVideoUri()
    {
      var uriConverter = new UriConverter(_webClient.Object);

      var youtubeVideoUri = "http://www.youtube.com/watch?v=test&feature=PlayList&p=575EC920C5A0FA78&index=28";
      var videoId = uriConverter.GetVideoId(youtubeVideoUri);

      Assert.AreEqual("test", videoId);
    }
    public IList<YoutubeVideo> GetVideos()
    {
      if (_videoFeed == null)
        return new List<YoutubeVideo>();

      var videos = new List<YoutubeVideo>();

      IList<String> szErrorList = new List<String>();
      foreach (Video videoFeedEntry in _videoFeed.Entries)
      {
        try
        {
          var video = new YoutubeVideo
          {
            Title = (videoFeedEntry.Title != null ? videoFeedEntry.Title : "[no title]"),
            Description = (videoFeedEntry.Description != null ? videoFeedEntry.Description : "[no description]"),
            Link = (videoFeedEntry.WatchPage != null ? videoFeedEntry.WatchPage.AbsoluteUri : "http://www.youtube.com/watch?v=" + videoFeedEntry.VideoId)
          };

          var uriConverter = new UriConverter(new WebClientImpl());
          var videoId = uriConverter.GetVideoId(video.Link);
          video.FlvUri = uriConverter.GetFlvUriFromYoutubeVideoUri(videoId);
          if (!string.IsNullOrEmpty(video.FlvUri))
          {
            videos.Add(video);
          }
        }
        catch (NotSignedInException)
        {
          szErrorList.Add(videoFeedEntry.Title);
        }
      }

      if (szErrorList.Count > 0)
        ShowErrors(szErrorList);

      return videos;
    }