private async void _mainEngine_OnYoutubeChatterClientMessageRecieved(YoutubeVideoManager manager, YoutubeChatterClientMessageType messageType) { // populates the media information if it's not populated and the tracker send the video id in the url await manager.PopulateMediaInfo(); Application.Current.Dispatcher.Invoke((Action)async delegate { // show YesNow Dialog Asking user if he want download the rest of the video or not await _showDownloadAskingDialog(manager); }); }
private async void Instance_OnNewVideoLastPacketRecieved(YoutubeVideoManager manager) { // populates the media information if it's not populated and the tracker send the video id in the url await manager.PopulateMediaInfo(); Application.Current.Dispatcher.Invoke((Action)async delegate { // show YesNow Dialog Asking user if he want download the rest of the video or not await _showDownloadAskingDialog(manager); }); //_startDownloadingVideo(manager); }
private async Task _showDownloadAskingDialog(YoutubeVideoManager manager) { // making sure the video info is populated if (manager.Video.VideoInfo is null) { YTrackLogger.Log($"Starting to download the rest of {manager.Video.VideoFingerPrint} before the info was populated ... ignoring download"); return; } var thumbnail = await Common.FetchThumbnail(manager.Video.VideoInfo.ThumbnailUrl); var thumbBytes = Helpers.Misc.ToImage(thumbnail.thumbnailBytes); // check if video is currently saved in database // if so .. I won't display store notification dialog if (_videosIds.Contains(manager.Video.VideoInfo.Id)) { return; } // check if the current video download dialog is already shown before if (_alreadyDownloadDialogedVideos.Contains(manager.Video.VideoInfo.Id)) { return; } var dialog = new NotificationYNDialog(manager.Video.VideoInfo.Title, thumbBytes); NotificationContainerWindow notificationWindow = new NotificationContainerWindow(dialog); notificationWindow.Show(); dialog.OnDialogResultAvailable += (sender, dialogResult) => { // add to already dialog list ... to make sure the dialog doesn't show for the same video twice _alreadyDownloadDialogedVideos.Add(manager.Video.VideoInfo.Id); if (dialogResult == NotificationDialogResult.Yes || ((dialogResult == NotificationDialogResult.NotChoosen) && Settings.Default.KeepIncompleteCaptureByDefault)) { _startDownloadingVideo(manager); } }; }
private void _startDownloadingVideo(YoutubeVideoManager manager) { if (!Directory.Exists(Settings.Default.OutputDirectory)) { Settings.Default.OutputDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonVideos); Settings.Default.Save(); } string outputPath = Path.Combine(Settings.Default.OutputDirectory, Helpers.Misc.RemoveIllegalPathChars(manager.Video.VideoInfo.Title)); new Thread(async() => { try { await manager.DownloadAndMultiplix(outputPath); } catch (Exception e) { YTrackLogger.Log("Exception Occured while Downloading and muxing : " + e.Message + "\n\n" + e.StackTrace); NotificationProvider.Instance.ShowMessageNotification("Capture Failed", "Error While Downloading The Rest Of The Video", NotificationMessageType.Error, this.Dispatcher); } }).Start(); }
private async void _mainEngine_OnNewYoutubeStored(YoutubeVideoManager manager, string path) { var video = await _storeVideo(manager.Video.VideoInfo, path); _showNewVideoCapturedNotification(video); }