public async Task UploadFileToYouTube(PodcastEpisode episode)
        {
            try
            {
                var youtubeService = new YouTubeService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer = await BuildAccountCredentialFromClientSecret(),
                    ApplicationName = "PodcastUploader"
                });

                var video = BuildVideo(episode);
                using (var fileStream = new FileStream(episode.LocalVideoFile, FileMode.Open))
                {
                    var videosInsertRequest = youtubeService.Videos.Insert(video, "snippet,status", fileStream, "video/*");
                    videosInsertRequest.ResponseReceived += (v) => videosInsertRequest_ResponseReceived(v, episode);

                    var chunkSize = 256 * 0x400 * 4;
                    videosInsertRequest.ChunkSize = chunkSize;
                    videosInsertRequest.Upload();
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }
 public Video BuildVideo(PodcastEpisode episode)
 {
     Video video = new Video();
     video.Snippet = new VideoSnippet();
     video.Snippet.Title = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(episode.EpisodeTitle);
     video.Snippet.Description = episode.EpisodeDescription;
     video.Snippet.Tags = episode.EpisodeKeywords;
     video.Snippet.CategoryId = "22"; // See https://developers.google.com/youtube/v3/docs/videoCategories/list
     video.Status = new VideoStatus { PrivacyStatus = "public" };// or "private" or "public" "unlisted"
     return video;
 }
 private void DownloadEpisode(PodcastEpisode episode)
 {
     episode.LocalEpisodeArtwork = EnsureLocalFileExists(episode.PodcastTitle, episode.RemoteEpisodeArtwork);
     episode.LocalAudioFile = EnsureLocalFileExists(episode.PodcastTitle, episode.RemoteAudioFile, defaultFileExtension: "mp3");
 }
 void videosInsertRequest_ResponseReceived(Video video, PodcastEpisode episode)
 {
     episode.YouTubeUrl = "http://youtube.com/watch?v=" + video.Id;
 }
Exemplo n.º 5
0
 public void SavePodcast(PodcastEpisode episode)
 {
     var history = new PodcastHistory(episode.PodcastTitle, episode.EpisodeID);
 }