public LocalFlvFile DownloadAndSaveAsTempFile(YoutubeVideo youTubeVideo)
    {
      youTubeVideo.ThrowIfNull("youTubeVideo");

      var localFile = new LocalFlvFile { FileName = GetTempFileNameWithExtension("flv") };

      var webClient = new WebClientImpl();
      webClient.DownloadFile(youTubeVideo.FlvUri, localFile.FileName, _stateNotifier.SetProgress);

      return localFile;
    }
    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;
    }
    public void DownloadOneSongAsAudioOnly()
    {
      var flvUri = "http://youtube.com/get_video?video_id=y6_-cLWwEU0&t=OEgsToPDskK4SK4mp23uC0fNwECBlETt";
      var video = new YoutubeVideo { Title = "cool song", FlvUri = flvUri };
      var downloader = new Downloader(new IStateNotifierMock());

      var files = downloader.AsAudioOnly(string.Empty, new List<YoutubeVideo> { video });

      Assert.AreEqual(1, files.Count);
      Assert.AreEqual("cool song.mp3", files[0].GetFileName());
    }
    public static string GetFileNameFromVideoWithExtension(YoutubeVideo video, string extension)
    {
      video.ThrowIfNull("video");

      return SantizeFileName(video.Title, extension);
    }