/// <summary> /// Split the video name to title-season-episode-info parts /// Separator: '.' (dot) /// </summary> /// <param name="videoNameText"></param> /// <returns></returns> public static ArrayList Splitter(string videoNameText) { Regex pattern; Match match; string matchResult = ""; string videoName = Renamer.ConvertSpaceToDot(videoNameText.ToLower()); string title = ""; string season = ""; string episode = ""; string info = ""; string[] videoNevDarabok = videoName.Split('.'); // hány tagú a cím int count = -1; foreach (string s in videoNevDarabok) { count++; //s01e02 pattern = new Regex(@"s[0-9][0-9]e[0-9][0-9]"); match = pattern.Match(s); if (match.Success) { matchResult = match.Value; season = matchResult.Substring(1, 2); episode = matchResult.Substring(4, 2); break; } //01x02 pattern = new Regex(@"[0-9][0-9]x[0-9][0-9]"); match = pattern.Match(s); if (match.Success) { matchResult = match.Value; season = matchResult.Substring(0, 2); episode = matchResult.Substring(3, 2); break; } //1x02 pattern = new Regex(@"[1-9]x[0-9][0-9]"); match = pattern.Match(s); if (match.Success) { matchResult = match.Value; season = "0" + matchResult.Substring(0, 1); episode = matchResult.Substring(2, 2); break; } //102 = s01e02 pattern = new Regex(@"[1-9][0-9]{2}"); match = pattern.Match(s); if (match.Success) { //102 in 2102? or 1302 = s13e02 Regex pattern2 = new Regex(@"[0-9]{4}"); Match match2 = pattern2.Match(s); if (!match2.Success) { matchResult = match.Value; season = "0" + matchResult.Substring(0, 1); episode = matchResult.Substring(1, 2); } else { matchResult = match2.Value; season = matchResult.Substring(0, 2); episode = matchResult.Substring(2, 2); } //lehet hogy a címbe van ez a szám ugyhogy tovább kell keresni for (int i = count + 1; i < videoNevDarabok.Length; i++) { string ss = videoNevDarabok[i]; if (ss.Equals("720p")) { continue; } if (ss.Equals("x264")) { continue; } if (ss.Equals("1080p")) { continue; } if (ss.Equals("480p")) { continue; } //s01e02 pattern = new Regex(@"s[0-9][0-9]e[0-9][0-9]"); match = pattern.Match(ss); if (match.Success) { matchResult = match.Value; season = matchResult.Substring(1, 2); episode = matchResult.Substring(4, 2); count = i; break; } //01x02 pattern = new Regex(@"[0-9][0-9]x[0-9][0-9]"); match = pattern.Match(ss); if (match.Success) { matchResult = match.Value; season = matchResult.Substring(0, 2); episode = matchResult.Substring(3, 2); count = i; break; } //1x02 pattern = new Regex(@"[1-9]x[0-9][0-9]"); match = pattern.Match(ss); if (match.Success) { matchResult = match.Value; season = "0" + matchResult.Substring(0, 1); episode = matchResult.Substring(2, 2); count = i; break; } //102 = s01e02 pattern = new Regex(@"[1-9][0-9]{2}"); match = pattern.Match(ss); if (match.Success) { // mivel szám után keresve talált egy másik számot ezért azonnal megkérdezi: using (SeasonEpisodeQForm questionForm = new SeasonEpisodeQForm(videoNameText)) { questionForm.ShowDialog(); season = questionForm.Season; episode = questionForm.Episode; string se = season + episode; for (int j = 0; j < videoNevDarabok.Length; j++) { // 4jegyű if (videoNevDarabok[j] == (se)) { count = j; break; } // 3jegyű if (videoNevDarabok[j] == (se.Substring(1, 3))) { count = j; break; } } } } } break; } } ArrayList list = new ArrayList(); //title: for (int i = 0; i < count; i++) { title += (videoNevDarabok[i] + "."); } //title = title.Substring(0, title.Length - 1); title = (title.Length == 0) ? title : title.Substring(0, title.Length - 1); list.Add(title); //season-episode: list.Add(season); list.Add(episode); //info: for (int i = count + 1; i < videoNevDarabok.Length - 1; i++) { info += (videoNevDarabok[i] + "."); } if (info.Length > 0) { info = info.Substring(0, info.Length - 1); if (info.EndsWith("hu") || info.EndsWith("en")) { info = info.Substring(0, info.Length - 3); } if (info.EndsWith("hun") || info.EndsWith("eng")) { info = info.Substring(0, info.Length - 4); } } list.Add(info); return(list); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainForm_Load(object sender, EventArgs e) { SplashScreen.UdpateStatusText("Beállítások betöltése..."); this.optForm = new OptionsForm(); this.optForm.Deactivate += new EventHandler(optForm_Deactivate); Thread.Sleep(50); SplashScreen.UdpateStatusText("Átnevező modul betöltése..."); this.ft = new FileTree(this.fileSystemTreeView, Settings.Default.defaultPath); this.fileSystemTreeView.AfterSelect += new TreeViewEventHandler(fileSystemTreeView_AfterSelect); this.watcher = new FileSystemWatcher(); this.watcher.Path = this.fileSystemTreeView.SelectedNode.FullPath; this.watcher.IncludeSubdirectories = true; this.watcher.Filter = "*.*"; this.watcher.Changed += new FileSystemEventHandler(OnChanged); this.watcher.Created += new FileSystemEventHandler(OnChanged); this.watcher.Deleted += new FileSystemEventHandler(OnChanged); this.watcher.Renamed += new RenamedEventHandler(OnRenamed); this.watcher.EnableRaisingEvents = true; this.ren = new Renamer(this.fileSystemTreeView, this.videoListBox, this.subtitleListBox, this.renameProgressBar, this.optForm.VideoCheckedListBox, this.optForm.SubtitleCheckedListBox, this.autoRenameButton); ren.RefreshWindows(); this.renameProgressBar.Hide(); this.videoListBox.ContextMenuStrip = AddVideoListContextMenuStrip(); this.subtitleListBox.ContextMenuStrip = AddSubtitleListContextMenuStrip(); ToolTip buttonToolTip = new ToolTip(); buttonToolTip.ToolTipTitle = "Automatikus átnevezés"; buttonToolTip.ToolTipIcon = ToolTipIcon.Info; buttonToolTip.UseFading = true; buttonToolTip.UseAnimation = true; buttonToolTip.IsBalloon = true; buttonToolTip.ShowAlways = true; buttonToolTip.AutoPopDelay = 5000; buttonToolTip.InitialDelay = 500; buttonToolTip.ReshowDelay = 500; buttonToolTip.SetToolTip(this.autoRenameButton, "CTRL + Klikk:" + Environment.NewLine + "A sorozat cím figyelmen kívül hagyása."); Thread.Sleep(50); SplashScreen.UdpateStatusText("Rendszerező modul betöltése..."); this.orgForm = new OrganizerForm(); this.orgForm.Deactivate += new EventHandler(orgForm_Deactivate); Thread.Sleep(50); SplashScreen.UdpateStatusText("Sorozat Naptár modul betöltése..."); this.scFrom = new SeriesCalenderFrom(); this.scFrom.Deactivate += new EventHandler(scFrom_Deactivate); Thread.Sleep(50); SplashScreen.UdpateStatusText("Kicsomagoló modul betöltése..."); this.unpForm = new UnpackerForm(this.optForm.VideoCheckedListBox); this.unpForm.Deactivate += new EventHandler(unpForm_Deactivate); Thread.Sleep(50); this.aboutForm = new AboutForm(); SplashScreen.UdpateStatusText("Modulok betöltve..."); Thread.Sleep(1000); //LoadTheme(Theme.DARK); this.Show(); SplashScreen.CloseSplashScreen(); this.Activate(); }
/// <summary> /// /// </summary> /// <param name="videoNameText"></param> /// <param name="subtitleList"></param> /// <returns></returns> private string SearchForSubtitle(string videoNameText, List <string> subtitleList, bool ignoretitle) { foreach (string subName in subtitleList) { if (subName.Contains(videoNameText.Substring(0, videoNameText.LastIndexOf(".")))) { return(""); } } ArrayList list = Renamer.Splitter(videoNameText); //string subName = ""; string title = (string)list[0]; string season = (string)list[1]; string episode = (string)list[2]; string info = (string)list[3]; //Renamer.DownloadSubtitle(videoNameText, title, int.Parse(season), int.Parse(episode), info); //Console.WriteLine(title); //Console.WriteLine("s: " + season + " e: " + episode); if (season.Equals("") && episode.Equals("")) { return(""); } string titleregex = (ignoretitle) ? @".*" : title.Replace(@".", @".*"); //Console.WriteLine(titleregex); Regex titlePattern = new Regex(titleregex); foreach (string subName in subtitleList) { string tempsubName = subName.ToLower(); StringBuilder sb; //Console.WriteLine(tempsubName); if (titlePattern.IsMatch(tempsubName)) { //s01e02 sb = new StringBuilder(); sb.Append("s" + season + "e" + episode); if (tempsubName.Contains(sb.ToString())) { return(subName); } //01x02 sb = new StringBuilder(); sb.Append(season + "x" + episode); if (tempsubName.Contains(sb.ToString())) { return(subName); } //1x02 sb = new StringBuilder(); sb.Append(season.Substring(1, 1) + "x" + episode); if (tempsubName.Contains(sb.ToString())) { return(subName); } //1302 = s13e02 sb = new StringBuilder(); sb.Append(season + "" + episode); if (tempsubName.Contains(sb.ToString())) { return(subName); } //102 = s01e02 sb = new StringBuilder(); sb.Append(season.Substring(1, 1) + "" + episode); if (tempsubName.Contains(sb.ToString())) { return(subName); } } } //no subtitle found return(""); }
/// <summary> /// /// </summary> /// <param name="nodes"></param> private void Organize(TreeNodeCollection nodes) { string seriesDirPath = Settings.Default.defaultPath; foreach (TreeNode node in nodes) { if (node.Checked) { DirectoryInfo dir = new DirectoryInfo(node.FullPath); try { foreach (FileInfo fi in dir.GetFiles()) { ArrayList list = Renamer.Splitter(fi.Name); string title = (string)list[0]; string season = (string)list[1]; string episode = (string)list[2]; string info = (string)list[3]; if (season.Equals("") && episode.Equals("")) { continue; } if (SettingsOrganizer.Default.title == "space") { title = Renamer.ConvertDotToSpace(title); info = Renamer.ConvertDotToSpace(info); } //Console.WriteLine(title); //Console.WriteLine(season); //Console.WriteLine(episode); //Console.WriteLine(info); string newDirName = mintaLabel.Text; newDirName = newDirName.Replace("{sorozatcím}", title); newDirName = newDirName.Replace("{évad}", SettingsOrganizer.Default.season + season); newDirName = newDirName.Replace("{epizód}", SettingsOrganizer.Default.episode + episode); newDirName = newDirName.Replace("{info}", info); //Console.WriteLine(newDirName); //Console.WriteLine(fi.DirectoryName + @"\" + newDirName); DirectoryInfo newDir = new DirectoryInfo(seriesDirPath + @"\" + newDirName); if (!newDir.Exists) { try { newDir.Create(); File.Move(fi.DirectoryName + @"\" + fi.Name, newDir + @"\" + fi.Name); } catch (IOException) { } } } } catch (IOException e) { MessageBox.Show(dir.Name + " device not ready", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } Organize(node.Nodes); } }