public void SetNumbersFromSubtitle(Subtitle st) { Numbers.Clear(); string name = Path.GetFileNameWithoutExtension(st.FileName).Replace(".", " "); Regex reg = new Regex(@"^.* [0-9]{1,2}x([0-9]{2})|^.* S[0-9]{1,2}E([0-9]{2})|^.* [0-9]{1,2}([0-9]{2})[^0-9]*", RegexOptions.IgnoreCase); GroupCollection col = reg.Match(name).Groups; for (int i = 1; i < col.Count; i++) if (col[i].Success) Numbers.Add(col[i].Value); }
private bool IsGoodType(Subtitle content) { try { if (RadioAllSubtitles.Checked) return true; if (RadioAssSubtitle.Checked && content.Type == Subtitle.SubtitleType.ASS) return true; if (RadioNoTagSubtitles.Checked && content.Type == Subtitle.SubtitleType.NoTag) return true; if (RadioTagSubtitles.Checked && content.Type == Subtitle.SubtitleType.Tag) return true; if (RadioUnknownSubtitles.Checked && content.Type == Subtitle.SubtitleType.Unknown) return true; } catch (Exception ex) { WriteLog(ex); } return false; }
private bool IsGoodLanguage(Subtitle content) { try { if (content.Language != "Unknown" && !content.IsFR && !content.IsEN) return false; if (!content.IsFR && !content.IsEN) return true; if (CheckFRSubtitle.Checked && content.IsFR) return true; if (CheckENSubtitle.Checked && content.IsEN) return true; } catch (Exception ex) { WriteLog(ex); } return false; }
private void FillPossibleFiles(Subtitle st) { try { CListSousTitresPossibles.Items.Clear(); if (st != null) { IList<string> folders = new List<string>(); foreach (DestinationFolder fold in ListDest.Items) if (TvShowEpisode.IsGoodDestination(fold, st.IsHD)) folders.Add(fold.FolderPath); st.FindVideos(folders); foreach (string str in st.ImpactedVideos) CListSousTitresPossibles.Items.Add(str); } } catch (Exception ex) { WriteLog(ex); } }
public override void FillSousTitres() { SousTitres = new List<Subtitle>(); string localpath = Path.Combine(TemporaryFolder, TvShow + Season) + @"\"; if (Directory.Exists(localpath)) Directory.Delete(localpath, true); MyExtensions.CreateDirectory(localpath); string localfile = Path.Combine(localpath, "page.html"); WebClient clt = new WebClient(); clt.DownloadFile(Url.Replace("?", string.Empty), localfile); string html = File.ReadAllText(localfile).Replace("\n", string.Empty); Regex reg = new Regex("(/images/edit.png)"); html = reg.Replace(html, "$1" + System.Environment.NewLine); reg = new Regex("Version ([^,]*),.*class=\"language\">([A-z]*)<.*(/original/\\d*/\\d*).*"); foreach (Match mat in reg.Matches(html)) { string subtitleName = String.Format("{3} {4}x{5} - {0} - {6} - {1}{2}.srt", mat.Groups[1].Value, DateTime.Now.ToTimestamp(), mat.Groups[0].Value.Contains("Hearing Impaired") ? " (HI)" : string.Empty, TvShow, Season, String.Join("-", Numbers), mat.Groups[2].Value); string file = Path.Combine(localpath, subtitleName); string url = "http://www.addic7ed.com" + mat.Groups[3].Value; try { if (Subtitle.AvailableExtensions.Contains(Path.GetExtension(file).Replace(".", string.Empty))) { Subtitle sub = new Subtitle(file, this, TvShow, Season, Numbers); sub.Url = url; sub.PreviousUrl = Url; sub.Language = mat.Groups[2].Value; SousTitres.Add(sub); } } catch { } } }
private void bgWorkerRename_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { DestinationFolder dest = new DestinationFolder(((SourceFolder)CboxRenameSource.SelectedItem).FolderPath); List<DestinationFolder> folder = new List<DestinationFolder>(); folder.Add(dest); List<string> fold = new List<string>(); fold.Add(dest.FolderPath); string[] files = new string[0]; //string[] errors = new string[0]; foreach (string ext in TvShowEpisode.AvailableExtensions) files = files.Concat(Directory.GetFiles(((SourceFolder)CboxRenameSource.SelectedItem).FolderPath, "*." + ext, SearchOption.AllDirectories)).ToArray(); foreach (string file in files) { TvShowEpisode ep = new TvShowEpisode(file); ep.FillTitle(0, folder); ep.FillFromFilter(TboxOldFilter.Text); ep.Filter = TboxSeriesFilter.Text; ep.FillPossibleFiles(folder); ep.Move(); //foreach (string error in ep.Rename()) // WriteLog(error); } files = new string[0]; foreach (string ext in Subtitle.AvailableExtensions) files = files.Concat(Directory.GetFiles(((SourceFolder)CboxRenameSource.SelectedItem).FolderPath, "*." + ext, SearchOption.AllDirectories)).ToArray(); foreach (string file in files) { Subtitle st = new Subtitle(file); st.FillFromFilter(TboxOldFilter.Text); st.FillSearchFilter(TboxSeriesFilter.Text); st.FindVideos(fold, true); st.Rename(true); } }