Ejemplo n.º 1
0
        private void DisplayLinks(string validatedLink)
        {
            //Create new videoDownloader object
            YoutubeVideoModel videoDownloader = new YoutubeVideoModel();

            //Set videoDownloader properties
            videoDownloader.Link = validatedLink;

            //Get list of Video objects
            videoDownloader.VideoInfo = FileDownloader.GetVideoInfos(videoDownloader);

            //Get Youtube ID
            int    length = videoDownloader.Link.Length;
            string ID     = videoDownloader.Link.Substring(length - 11, 11);

            //Get Youtube Thumbnail
            //http://stackoverflow.com/questions/2068344/how-do-i-get-a-youtube-video-thumbnail-from-the-youtube-api
            string thumbnailURL = "http://img.youtube.com/vi/" + ID + "/1.jpg";

            Label2.Text  = "Right Click and Save As to Download<br/>";
            Label2.Text += "<img src='" + thumbnailURL + "'>";
            Label2.Text += videoDownloader.VideoInfo.First().Title + "<br/>";

            foreach (VideoInfo vi in videoDownloader.VideoInfo)
            {
                Label2.Text += "<a href=" + vi.DownloadUrl + ">" + vi.Resolution + " " + vi.VideoExtension + "</a><br/>";
            }
        }
        private async Task GetVideoMetadataAsync(YoutubeVideoModel model)
        {
            try
            {
                var video = await _client.GetVideoAsync(model.Id);

                model.ApplyMetadata(video);
            }
            catch
            {
                throw new YoutubeHandlerException(model.Id, "Could not pull metadata.");
            }
        }
        private async Task GetStreamInfoAsync(YoutubeVideoModel model)
        {
            try
            {
                var streamInfoSet = await _client.GetVideoMediaStreamInfosAsync(model.Id);

                var muxedInfo = streamInfoSet.Muxed.WithHighestVideoQuality();

                model.MediaStreamInfo = muxedInfo;
            }
            catch
            {
                throw new YoutubeHandlerException(model.Id, "Could not get media stream info set.");
            }
        }
        private async Task DownloadVideoStreamAsync(YoutubeVideoModel model)
        {
            try
            {
                var progress = new Progress <double>(x => model.DownloadProgress = x);

                model.Path = _config.DownloadDirectory + model.FileName;

                await _client.DownloadMediaStreamAsync(model.MediaStreamInfo, model.Path, progress);
            }
            catch
            {
                throw new YoutubeHandlerException(model.Id, "Media stream could not be downloaded.");
            }
        }
Ejemplo n.º 5
0
        private void DisplayLinks(string validatedLink)
        {
            //Create new videoDownloader object
            YoutubeVideoModel videoDownloader = new YoutubeVideoModel();

            //Set videoDownloader properties
            videoDownloader.Link = validatedLink;

            //Get video
            videoDownloader.VideoInfo = FileDownloader.GetVideoInfos(videoDownloader);
            Label2.Text = "Right Click and Save As to Download<br/>";
            foreach (VideoInfo vi in videoDownloader.VideoInfo)
            {
                Label2.Text += "<a href=" + vi.DownloadUrl + ">" + vi.Title + " " + vi.Resolution + " " + vi.VideoExtension + "</a><br/>";
            }
        }
Ejemplo n.º 6
0
        private async void AddClipboard()
        {
            if (Clipboard.ContainsText())
            {
                string clipBoardText = Clipboard.GetText();

                var videoInfo = await DialogHost.Show(new LoadingView(clipBoardText));

                if (videoInfo == null)
                {
                    return;
                }
                YoutubeVideoModel info = (YoutubeVideoModel)videoInfo;
                info.DeleteVideo = DeleteIteam;
                MainVideoList.Add(info);
            }
        }
Ejemplo n.º 7
0
        private async void AddViewShow()
        {
            try
            {
                var videoInfo = await DialogHost.Show(new AddVideoPopup());

                if (videoInfo == null)
                {
                    return;
                }

                YoutubeVideoModel info = (YoutubeVideoModel)videoInfo;
                info.DeleteVideo = DeleteIteam;
                MainVideoList.Add(info);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
 private async Task DownloadVideoAsync(YoutubeVideoModel model)
 {
     await GetVideoMetadataAsync(model);
     await GetStreamInfoAsync(model);
     await DownloadVideoStreamAsync(model);
 }