private void Window_Loaded(object sender, RoutedEventArgs e) { List <CPES> tabloList = TabloAPI.GetCpesList(); tabloComboBox.Items.Clear(); if (tabloList.Count > 0) { txtTabloIPAddress.Visibility = Visibility.Hidden; foreach (CPES cpes in tabloList) { tabloComboBox.Items.Add(cpes); } tabloComboBox.SelectedIndex = 0; ValidateTablo(((CPES)tabloComboBox.SelectedItem).private_ip); } else { txtTabloIPAddress.Visibility = Visibility.Visible; tabloComboBox.Visibility = Visibility.Hidden; } }
private async Task GetRecordingVideo(IPEndPoint ipEndPoint, Recording recording, IProgress <ProgressBarInfo> secondaryProgressBar, IProgress <string> secondaryLabel) { try { string path = string.Format("{0}\\TempTabloExtract", Path.GetTempPath()); if (!Directory.Exists(path)) { log.InfoFormat("Creating directory: {0}", path); Directory.CreateDirectory(path); } } catch (IOException ex) { string text = string.Format("Unable to create temporary directory at '{0}\\TempTabloExtract'", Path.GetTempPath()); log.Error(text, ex); MessageBox.Show(text); return; } try { if (!Directory.Exists(OutputDirectory)) { Directory.CreateDirectory(OutputDirectory); } } catch (IOException ex) { string text = string.Format("Unable to create output directory at '{0}'", OutputDirectory); log.Error(text, ex); MessageBox.Show(text); return; } IMediaNamingConvention mediaNamingConvention = ServiceLocator.Current.GetInstance <IMediaNamingConvention>(); string OutputFile; if (recording.Type == RecordingType.Episode) { OutputFile = mediaNamingConvention.GetEpisodeOutputFileName(OutputDirectory, recording); string dir = Path.GetDirectoryName(OutputFile); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } } else if (recording.Type == RecordingType.Movie) { OutputFile = mediaNamingConvention.GetMovieOutputFileName(OutputDirectory, recording); string dir = Path.GetDirectoryName(OutputFile); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } } else if (recording.Type == RecordingType.Sports) { OutputFile = mediaNamingConvention.GetSportsOutputFileName(OutputDirectory, recording); string dir = Path.GetDirectoryName(OutputFile); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } } else if (recording.Type == RecordingType.Manual) { OutputFile = mediaNamingConvention.GetManualOutputFileName(OutputDirectory, recording); } else { OutputFile = mediaNamingConvention.GetOtherOutputFileName(OutputDirectory, recording); } if (File.Exists(OutputFile)) { log.InfoFormat(String.Format("File {0} already exists - skipping", OutputFile)); return; } if (!File.Exists(FFMPEGLocation)) { string notFound = "FFMPEG could not be found. It must be located before you can proceed."; log.InfoFormat(notFound); MessageBox.Show(notFound); return; } try { FileInfo fileInfo = new FileInfo(FFMPEGLocation); if (fileInfo.Name != "ffmpeg.exe") { string notFound = "The file name provided for FFMPEG was not \"ffpmeg.exe\". It must be located before you can proceed."; log.InfoFormat(notFound); MessageBox.Show(notFound); return; } } catch (Exception ex) { string notFound = "There was a problem reading from the FFMPEG exe. It must be located before you can proceed."; log.Info(notFound, ex); MessageBox.Show(notFound); return; } RecordingWatch recordingWatch = TabloAPI.GetRecordingWatch(recording, TabloEndPoint); if (String.IsNullOrWhiteSpace(recordingWatch.playlist_url)) { log.ErrorFormat("recordingWatch.playlist_url for {0} is empty.", recording); } else if (await ProcessVideosInFFMPEG(recordingWatch.playlist_url, recording, OutputFile, FFMPEGLocation, secondaryProgressBar, secondaryLabel)) { log.InfoFormat("playlist_url: {0}", recordingWatch.playlist_url); string recordingJson = JsonConvert.SerializeObject(recording, Formatting.Indented); string recordingOutputFile = Path.ChangeExtension(OutputFile, ".json"); if (File.Exists(recordingOutputFile)) { File.Delete(recordingOutputFile); } File.WriteAllText(recordingOutputFile, recordingJson); if (!File.Exists(recordingOutputFile)) { log.InfoFormat("Recording file: {0} written to disk.", recordingOutputFile); } } }