public EpisodeInfo (int index,
				int number,
				UtilsInputFiles.FileDesc videoFileDesc,
				UtilsInputFiles.FileDesc audioFileDesc,
				UtilsInputFiles.FileDesc sub1FileDesc,
				UtilsInputFiles.FileDesc sub2FileDesc,
				StreamInfo videoStreamInfo,
				StreamInfo audioStreamInfo,
				StreamInfo sub1StreamInfo,
				StreamInfo sub2StreamInfo)
		{
			m_index = index;
			m_number = number;
			m_videoFileDesc = videoFileDesc;
			m_audioFileDesc = audioFileDesc;
			m_subsFileDesc[0] = sub1FileDesc;
			m_subsFileDesc[1] = sub2FileDesc;
			m_videoStreamInfo = videoStreamInfo;
			m_audioStreamInfo = audioStreamInfo;
			m_subStreamInfos[0] = sub1StreamInfo;
			m_subStreamInfos[1] = sub2StreamInfo;
		}
#pragma warning restore 0414, 0169

		public UtilsAlignSubToAudio(List<LineInfo> lines, UtilsInputFiles.FileDesc audioFile) {
			// TODO: implement align sub to audio 
			m_audioFileDesc = audioFile;
		}
Esempio n. 3
0
		private void ConnectEventsSubitleWindowOptions() {

			m_subtitleOptionsWindow.DeleteEvent += delegate(object obj, DeleteEventArgs args) {
				m_subtitleOptionsWindow.Hide ();
				args.RetVal = true; // this prevents the window from being actually getting deleted
			};

			m_buttonSubOptionsApply.Clicked += delegate(object sender, EventArgs e) {

				Gtk.Entry currentEntry = m_subOptionsWindow_subIndex == 0 ? m_entryTargetLanguage : m_entryNativeLanguage;
				UtilsInputFiles allFiles = new UtilsInputFiles(currentEntry.Text);
				allFiles.SetPropertiesOfFirstFile("enc", InfoEncoding.getEncodings()[m_comboboxSubEncoding.Active].ShortName);

				if(m_comboboxSubStream.Active >= 0)
					allFiles.SetPropertiesOfFirstFile("stream", m_subOptionsWindowStreamIndices[m_comboboxSubStream.Active].ToString());

				//allFiles.SetPropertiesOfFirstFile("stream", );
				currentEntry.Text = allFiles.ToString();
				m_subtitleOptionsWindow.Hide();
			};
		}
Esempio n. 4
0
		private String AddFilesToEntry(String originalString, String[] filesToAdd, String errorMessagePrefix) {

			UtilsInputFiles utilsInputFile;
			try {
				utilsInputFile = new UtilsInputFiles (originalString);
			} catch (Exception ex) {
				SetErrorMessage (errorMessagePrefix + ex.Message);
				return originalString;
			}

			foreach (String filename in filesToAdd) {
				if (String.IsNullOrWhiteSpace (filename))
					continue;
				utilsInputFile.AddFile(filename);
			}

			return utilsInputFile.ToString();
		}
Esempio n. 5
0
		/// <summary>
		/// Tries to parse and evaluate an attributed file path. If one of the files does not exist, an
		/// exception will be thrown.
		/// </summary>
		/// <returns>The input files string.</returns>
		/// <param name="str">String.</param>
		/// <param name="errorMessagePrefix">Prefix for exception.</param>
		private void TryParseInputFilesString(String str, String errorMessagePrefix) {
			try {
				// parse attributed file string
				UtilsInputFiles utilsInputFile = new UtilsInputFiles (m_entryTargetLanguage.Text);

				// try to find all files
				foreach (UtilsInputFiles.FileDesc fileDesc in utilsInputFile.GetFileDescriptions ())
					if (!File.Exists (fileDesc.filename))
						throw new Exception("File \"" + fileDesc.filename + "\" does not exist!");

			} catch (Exception ex) {
				throw new Exception (errorMessagePrefix + ex.Message);
			}
		}
Esempio n. 6
0
		private void OpenSubtitleWindow(int subIndex) {
			m_subtitleOptionsWindow.Title = "Sub" + (subIndex + 1) + " Options";

			Gtk.Entry currentEntry = subIndex == 0 ? m_entryTargetLanguage : m_entryNativeLanguage;
			m_subOptionsWindow_subIndex = subIndex;

			// read properties of first file to get selected stream and show them in combobox
			UtilsInputFiles uif = new UtilsInputFiles(currentEntry.Text);
			List<UtilsInputFiles.FileDesc> fileDescs = uif.GetFileDescriptions ();

			String selectedEncoding = "utf-8";
			String selectedStreamString = null;
			if (fileDescs.Count > 0 && fileDescs [0].properties.ContainsKey ("enc"))
				selectedEncoding = fileDescs [0].properties ["enc"];
			if (fileDescs.Count > 0 && fileDescs [0].properties.ContainsKey ("stream"))
				selectedStreamString = fileDescs [0].properties ["stream"];

			int selectedStreamIndex = -1;
			if (!Int32.TryParse (selectedStreamString, out selectedStreamIndex))
				selectedStreamIndex = -1;

			// get all streams in first video file
			List<StreamInfo> firstVideoFileStreams = null;
			for (int index = 0; index < fileDescs.Count; index++) {
				String thisFilename = fileDescs [index].filename;

				if (!String.IsNullOrWhiteSpace (thisFilename) && UtilsCommon.GetFileTypeByFilename (thisFilename) == UtilsCommon.FileType.FT_VIDEO) {
					if (!File.Exists (thisFilename))
						throw new Exception ("File \"" + thisFilename + "\" does not exist");
					firstVideoFileStreams = StreamInfo.ReadAllStreams (thisFilename);

					break;
				}
			}

			// fill streams box
			int selectedEntry_SubStreams = -1;
			int numberOfEntries_SubStreams = 0;
			m_liststoreSubStreams.Clear();
			m_subOptionsWindowStreamIndices.Clear ();
			if (firstVideoFileStreams != null) {
				for (int index = 0; index < firstVideoFileStreams.Count; index++) {
					if (firstVideoFileStreams [index].StreamTypeValue == StreamInfo.StreamType.ST_SUBTITLE) {
						selectedEntry_SubStreams = selectedEntry_SubStreams == -1 ? 0 : selectedEntry_SubStreams;
						if (index == selectedStreamIndex)
							selectedEntry_SubStreams = numberOfEntries_SubStreams;
						numberOfEntries_SubStreams++;

						m_subOptionsWindowStreamIndices.Add (index);
						m_liststoreSubStreams.AppendValues ("Stream " + index + " - " + firstVideoFileStreams [index].Language);
					}
				}
			}
			if(selectedEntry_SubStreams >= 0)
				m_comboboxSubStream.Active = selectedEntry_SubStreams;


			// fill encodings in subtitle options
			m_liststoreSubEncoding.Clear();
			int encodingIndex = 0;
			int utf8index = -1;
			int selectedEncodingIndex = -1;
			foreach (InfoEncoding enc in InfoEncoding.getEncodings()) {
				if (enc.ShortName == "utf-8")
					utf8index = encodingIndex;
				if (enc.ShortName == selectedEncoding)
					selectedEncodingIndex = encodingIndex;
				m_liststoreSubEncoding.AppendValues (enc.LongName);
				encodingIndex++;
			}
			if (selectedEncodingIndex >= 0)
				m_comboboxSubEncoding.Active = selectedEncodingIndex;
			else if (utf8index >= 0)
				m_comboboxSubEncoding.Active = utf8index;
			else
				m_comboboxSubEncoding.Active = 0;


			m_subtitleOptionsWindow.ShowAll ();
		}
Esempio n. 7
0
		private static List<EpisodeInfo> GenerateEpisodeInfos(Settings settings) {

			// get all filenames
			UtilsInputFiles sub1Files = new UtilsInputFiles (settings.TargetFilePath);
			UtilsInputFiles sub2Files = new UtilsInputFiles (settings.NativeFilePath);
			UtilsInputFiles videoFiles = new UtilsInputFiles (settings.VideoFilePath);

			List<UtilsInputFiles.FileDesc> sub1FileDescs = sub1Files.GetFileDescriptions();
			List<UtilsInputFiles.FileDesc> sub2FileDescs = sub2Files.GetFileDescriptions();
			List<UtilsInputFiles.FileDesc> videoFileDescs = videoFiles.GetFileDescriptions();

			bool noSub2 = sub2FileDescs.Count == 0; // no subtitles in native language available
			bool noVideos = videoFileDescs.Count == 0; // no video files available
			bool noAudio = noVideos; // TODO

			int numberOfEpisodes = sub1FileDescs.Count;
			if(numberOfEpisodes != sub2FileDescs.Count && !noSub2)
				throw new Exception("Number of files in target languages and number of files in native language does not match.");
			if(numberOfEpisodes != videoFileDescs.Count && !noVideos)
				throw new Exception("Number of files in target languages and number of video files does not match.");

			// fill episode info
			List<EpisodeInfo> episodeFiles = new List<EpisodeInfo>();
			for(int episodeIndex = 0; episodeIndex < numberOfEpisodes; episodeIndex++) {
				int episodeNumber = episodeIndex + settings.FirstEpisodeNumber;
				var videoFileDesc = noVideos ? null : videoFileDescs[episodeIndex];
				var audioFileDesc = noAudio ? null : videoFileDescs[episodeIndex];
				var sub1FileDesc = sub1FileDescs[episodeIndex];
				var sub2FileDesc = noSub2 ? null : sub2FileDescs[episodeIndex];
				var videoStreamInfo = noVideos ? null : UtilsVideo.ChooseStreamInfo(videoFileDesc.filename, videoFileDesc.properties, StreamInfo.StreamType.ST_VIDEO);
				var audioStreamInfo = noAudio ? null : UtilsVideo.ChooseStreamInfo(audioFileDesc.filename, audioFileDesc.properties, StreamInfo.StreamType.ST_AUDIO);
				var sub1StreamInfo = UtilsVideo.ChooseStreamInfo(sub1FileDesc.filename, sub1FileDesc.properties, StreamInfo.StreamType.ST_SUBTITLE);
				var sub2StreamInfo = noSub2 ? null : UtilsVideo.ChooseStreamInfo(sub2FileDesc.filename, sub2FileDesc.properties, StreamInfo.StreamType.ST_SUBTITLE);
				episodeFiles.Add(new EpisodeInfo(episodeIndex, episodeNumber, videoFileDesc, audioFileDesc, sub1FileDesc, sub2FileDesc, videoStreamInfo, audioStreamInfo, sub1StreamInfo, sub2StreamInfo));
			}

			return episodeFiles;
		}