Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ScanProcesses()
- {
- System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcesses();
- string titleName = processes.FirstOrDefault(x => x.ProcessName == "mpc-hc64")?.MainWindowTitle;
- if (String.IsNullOrWhiteSpace(titleName)) { return; }
- Dictionary<string, string> title = new Dictionary<string, string>();
- System.Text.RegularExpressions.Regex reg;
- reg = new System.Text.RegularExpressions.Regex(@"- ?(\d+)(\(\d*\))?");
- var match = reg.Match(titleName);
- string ep = "";
- if (match.Index != 0 && match.Length != 0)
- {
- ep = titleName.Substring(match.Index, match.Length).Replace("- ", "");
- titleName = reg.Replace(titleName, "");
- }
- title.Add("episode", ep);
- reg = new System.Text.RegularExpressions.Regex(@"TV(\d*)");
- match = reg.Match(titleName);
- string season = "";
- if (match.Index != 0 && match.Length != 0)
- {
- season = titleName.Substring(match.Index, match.Length).Replace("TV", "");
- titleName = reg.Replace(titleName, "");
- }
- if (String.IsNullOrWhiteSpace(season))
- {
- season = "1";
- }
- title.Add("season", season);
- reg = new System.Text.RegularExpressions.Regex(@"\[.*?\]|\(.*?\)");
- string name = reg.Replace(titleName, "");
- title.Add("name", name);
- Console.WriteLine("{0} | {1} | {2}", title["name"], title["episode"], title["season"]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement