Exemple #1
0
        public static List <LineInfo> ParseSubtitleWithPostProcessing(Settings settings, PerSubtitleSettings perSubtitleSettings, string filename, Dictionary <String, String> properties)
        {
            List <LineInfo> lines = ParseSubtitle(settings, filename, properties);

            BeautifyLines(lines);
            return(lines);
        }
Exemple #2
0
        /// <summary>
        /// Align subtitle line by constant value, to audio or to other subtitle based on settings in "perSubSettings".
        /// </summary>
        public static void AlignSub(List <LineInfo> lineList, List <LineInfo> referenceList, EpisodeInfo epInfo, Settings settings, PerSubtitleSettings thisSubSettings)
        {
            switch (thisSubSettings.AlignMode)
            {
            case PerSubtitleSettings.AlignModes.ByConstantValue:
                UtilsSubtitle.ShiftByTime(lineList, thisSubSettings.SubDelay);
                break;

            case PerSubtitleSettings.AlignModes.ToAudio:
                UtilsAlignSubToAudio alignToAudio = new UtilsAlignSubToAudio(lineList, epInfo.AudioFileDesc);
                UtilsSubtitle.ShiftByTime(lineList, alignToAudio.GetBestShiftValue());
                break;

            case PerSubtitleSettings.AlignModes.ToSubtitle:
                if (referenceList == null)
                {
                    throw new Exception("Can not align subtitle to other non-existent subtitle.");
                }
                UtilsAlignSubToSub alignToSub = new UtilsAlignSubToSub(lineList, referenceList);
                alignToSub.Retime();
                break;
            }
        }
		/// <summary>
		/// Reads all subtitle files.
		/// </summary>
		/// <returns>Every entry in the outer list refers to exactly one subtitle file and for every file there is a list of all lines in it.</returns>
		/// <param name="settings">Settings.</param>
		/// <param name="attributedFilePaths">Attributed file path string.</param>
		private static List<List<LineInfo>> ReadAllSubtitleFiles (Settings settings, PerSubtitleSettings thisSubtitleSettings, List<EpisodeInfo> episodeInfos, int subtileIndex, InfoProgress progressInfo)
		{
			// read all lines in every subtitle file
			List<List<LineInfo>> lineInfosPerEpisode = new List<List<LineInfo>> ();
			foreach (EpisodeInfo episodeInfo in episodeInfos) {
				UtilsInputFiles.FileDesc fileDesc = episodeInfo.SubsFileDesc [subtileIndex];
				if (fileDesc == null || String.IsNullOrWhiteSpace (fileDesc.filename))
					lineInfosPerEpisode.Add (null);
				else
					lineInfosPerEpisode.Add (UtilsSubtitle.ParseSubtitleWithPostProcessing (settings, thisSubtitleSettings, fileDesc.filename, fileDesc.properties));
				progressInfo.ProcessedSteps (1);

				if (progressInfo.Cancelled)
					return null;
			}

			return lineInfosPerEpisode;
		}