public void GetMovie(IMovie m) { _selectedMovie = m; var subs = new SubtitleList(); subs.AddRange(m.Subtitles); for (int x = 0; x < subs.Count; x++) { var s = subs[x]; SubGrid.Rows.Add(); var c = SubGrid.Rows[x].Cells[0]; c.Value = s.Frame; c = SubGrid.Rows[x].Cells[1]; c.Value = s.X; c = SubGrid.Rows[x].Cells[2]; c.Value = s.Y; c = SubGrid.Rows[x].Cells[3]; c.Value = s.Duration; c = SubGrid.Rows[x].Cells[4]; c.Value = $"{s.Color:X8}"; c.Style.BackColor = Color.FromArgb((int)s.Color); c = SubGrid.Rows[x].Cells[5]; c.Value = s.Message; } }
private void FileNameLoad(string filePath) { DirectoryInfo directoryInfo = new DirectoryInfo(filePath); List <ListViewItem> videoDeleteList = new List <ListViewItem>(); List <ListViewItem> subtitleDeletList = new List <ListViewItem>(); VideoList.FileNameLoad(directoryInfo); SubtitleList.FileNameLoad(directoryInfo); foreach (ListViewItem videoname in VideoList.fileNameListView.Items) { foreach (ListViewItem subtitlename in SubtitleList.fileNameListView.Items) { if (videoname.ToString() == subtitlename.ToString()) { videoDeleteList.Add(videoname); subtitleDeletList.Add(subtitlename); } } } foreach (var item in videoDeleteList) { VideoList.fileNameListView.Items.Remove(item); } foreach (var item in subtitleDeletList) { SubtitleList.fileNameListView.Items.Remove(item); } }
public void GetMovie(IMovie m) { _selectedMovie = m; var subs = new SubtitleList(); subs.AddRange(m.Subtitles); for (int x = 0; x < subs.Count; x++) { var s = subs[x]; SubGrid.Rows.Add(); var c = SubGrid.Rows[x].Cells[0]; c.Value = s.Frame; c = SubGrid.Rows[x].Cells[1]; c.Value = s.X; c = SubGrid.Rows[x].Cells[2]; c.Value = s.Y; c = SubGrid.Rows[x].Cells[3]; c.Value = s.Duration; c = SubGrid.Rows[x].Cells[4]; c.Value = String.Format("{0:X8}", s.Color); c.Style.BackColor = Color.FromArgb((int)s.Color); c = SubGrid.Rows[x].Cells[5]; c.Value = s.Message; } }
public ActionResult Upload(SubtitlesFileUploadViewModel form) { try { // parse subtitles string finResult = new StreamReader(form.FinnishSubtitleFile.InputStream, Encoding.GetEncoding(1250)).ReadToEnd(); SubtitleList finSubList = srtToSubtitleList(finResult); string engResult = new StreamReader(form.EnglishSubtitleFile.InputStream, Encoding.GetEncoding(1250)).ReadToEnd(); SubtitleList enSubList = srtToSubtitleList(engResult); finSubList.CompareTo(enSubList); // send to 'compare' SubtitleCompareVM vm = new SubtitleCompareVM(); vm.leftList = finSubList; vm.rightList = enSubList; string id = SaveSubtitleFiles(form); return(RedirectToAction("Compare", new { controller = "Subtitles", action = "Compare", id = id })); } catch (Exception e) { Debug.WriteLine(e.Message); return(HttpNotFound(e.Message)); } }
/// <summary> /// The create subtitle. /// </summary> /// <param name="job"> /// The job. /// </param> /// <returns> /// The <see cref="Encode.Subtitle"/>. /// </returns> private static Subtitle CreateSubtitle(EncodeJob job) { Subtitle subtitle = new Subtitle { Search = new Search { Enable = false, Default = false, Burn = false, Forced = false }, SubtitleList = new List <SubtitleList>() }; foreach (SourceSubtitle item in job.Subtitles.SourceSubtitles) { // Handle Foreign Audio Search if (item.TrackNumber == 0) { subtitle.Search.Enable = true; subtitle.Search.Burn = item.BurnedIn; subtitle.Search.Default = item.Default; subtitle.Search.Forced = item.Forced; } else { SubtitleList track = new SubtitleList { Burn = item.BurnedIn, Default = item.Default, Force = item.Forced, ID = item.TrackNumber, Track = (item.TrackNumber - 1) }; subtitle.SubtitleList.Add(track); } } foreach (SrtSubtitle item in job.Subtitles.SrtSubtitles) { SubtitleList track = new SubtitleList { Track = -1, // Indicates SRT Default = item.Default, Offset = item.Offset, Burn = item.BurnedIn, SRT = new SRT { Filename = item.FileName, Codeset = item.CharacterCode, Language = item.LanguageCode } }; subtitle.SubtitleList.Add(track); } return(subtitle); }
public Bk2Movie() { Subtitles = new SubtitleList(); Comments = new List<string>(); Filename = string.Empty; IsCountingRerecords = true; _mode = Moviemode.Inactive; _makeBackup = true; Header[HeaderKeys.MOVIEVERSION] = "BizHawk v2.0.0"; }
private void EditSubtitlesForm_Load(object sender, EventArgs e) { var subs = new SubtitleList(); subs.AddRange(_selectedMovie.Subtitles); for (int x = 0; x < subs.Count; x++) { var s = subs[x]; SubGrid.Rows.Add(); var c = SubGrid.Rows[x].Cells[0]; c.Value = s.Frame; c = SubGrid.Rows[x].Cells[1]; c.Value = s.X; c = SubGrid.Rows[x].Cells[2]; c.Value = s.Y; c = SubGrid.Rows[x].Cells[3]; c.Value = s.Duration; c = SubGrid.Rows[x].Cells[4]; c.Value = $"{s.Color:X8}"; c.Style.BackColor = Color.FromArgb((int)s.Color); c = SubGrid.Rows[x].Cells[5]; c.Value = s.Message; } if (_readOnly) { // Set all columns to read only for (int i = 0; i < SubGrid.Columns.Count; i++) { SubGrid.Columns[i].ReadOnly = true; } Text = "View Subtitles"; } if (SubGrid.Rows.Count > 8) { var x = Height + ((SubGrid.Rows.Count - 8) * 21); Height = x < 600 ? x : 600; } }
public ActionResult Compare(string id) { SubtitleCompare st = SubtitleCompare.SingleOrDefault("WHERE Link=@0", id); if (st == null || st.SubtitleFileA == 0 || st.SubtitleFileB == 0) { return(RedirectToAction("Index")); } SubtitleFile A = SubtitleFile.FirstOrDefault("WHERE ID=@0", st.SubtitleFileA); SubtitleFile B = SubtitleFile.FirstOrDefault("WHERE ID=@0", st.SubtitleFileB); SubtitleFile fiFile = A.LanguageID == FI ? A : B; string fiFullPath = Path.Combine(Server.MapPath(FILE_PATH), fiFile.Filename); SubtitleFile enFile = A.LanguageID == EN ? A : B; string enFullPath = Path.Combine(Server.MapPath(FILE_PATH), enFile.Filename); if (!System.IO.File.Exists(fiFullPath) || !System.IO.File.Exists(enFullPath)) { return(HttpNotFound("File not found on server.")); } string fiFileContent = System.IO.File.ReadAllText(fiFullPath, Encoding.GetEncoding(1250)); SubtitleList fiSubList = srtToSubtitleList(fiFileContent); string enFileContent = System.IO.File.ReadAllText(enFullPath, Encoding.GetEncoding(1250)); SubtitleList enSubList = srtToSubtitleList(enFileContent); fiSubList.CompareTo(enSubList); // send to 'compare' SubtitleCompareVM vm = new SubtitleCompareVM(); vm.leftList = fiSubList; vm.rightList = enSubList; return(View("Compare", vm)); }
private SubtitleList srtToSubtitleList(string fileContent) { //TODO: detect encoding better. Assuming encoding is correct... // assuming file is .srt type. SubtitleList subList = new SubtitleList(); int entryNum = 0; int entryStatus = 0; // 0 = expecting new entry, 1 = expecting time, 2 = reading text until empty line. SubtitleEntry entry = null; using (StringReader reader = new StringReader(fileContent)) { string line; int lineNum = 0; while ((line = reader.ReadLine()) != null) { Debug.WriteLine(lineNum + ": " + line); switch (entryStatus) { case 0: entryNum++; if (int.Parse(line) != entryNum) { throw new Exception("Bad format in line " + lineNum + ". Expected " + entryNum + " got " + line); } entry = new SubtitleEntry(); subList.Add(entry); entry.Index = entryNum; entryStatus = 1; break; case 1: if (!srtTime.IsMatch(line)) { throw new Exception("Bad format in time line " + lineNum); } string startStr = "1/1/0001 " + line.Substring(0, 12).Replace(',', '.'); string endStr = "1/1/0001 " + line.Substring(17, 12).Replace(',', '.'); DateTime st = Convert.ToDateTime(startStr); entry.StartTime = st.Ticks; DateTime et = Convert.ToDateTime(endStr); entry.EndTime = et.Ticks; entryStatus = 2; break; case 2: // all of these lines until empty string is the entry string if (String.IsNullOrEmpty(line)) { entryStatus = 0; } else { var textLine = StripHTML(line); if (String.IsNullOrEmpty(entry.Text)) { entry.Text = textLine; } else { entry.Text += " " + textLine; } } break; default: break; } lineNum++; } } return(subList); }