public static string GetChoice(HashSet <Series> s) { ChoiceWindow cw = new ChoiceWindow(s); cw.ShowDialog(); return(cw.choice); }
private void SetSeriesDestinationPath(Series s) { Debug.WriteLine("------Before getting destination path------"); string destinationPath = GetDestinationPath(s); // We got no current folder for the series, so we create one. if (destinationPath.Length == 0) { Debug.WriteLine("No folder exists for the series, so we create one"); if (setObj.DestinationList.Count > 1) { ChoiceWindow cw = new ChoiceWindow(setObj.DestinationList); cw.ShowDialog(); destinationPath = cw.choice; } else { destinationPath = setObj.DestinationList.First(); } s.Name = Utility.SanitizeString(s.Name); destinationPath += '\\' + s.Name; Debug.WriteLine("Folder name after creation: " + destinationPath); } Debug.WriteLine("Current destination path: " + destinationPath); destinationPath += "\\Season " + s.Season; Debug.WriteLine("Current destination path: " + destinationPath); s.Name = Utility.SanitizeString(s.Name.Trim(' ')); s.Title = Utility.SanitizeString(s.Title); Debug.WriteLine("Series title: " + s.Title); Tuple <List <int>, string> format = Utility.ParseSeriesFormat(setObj.CustomFormat); if ((setObj.CustomFormat != "" || setObj.CustomFormat != null) && format.Item2 != "") { string fm = "\\" + format.Item2; destinationPath += String.Format(fm, Utility.SeriesParameters); destinationPath += String.Format(fm, s.Name, s.Season, s.Episode, s.Title); } else { destinationPath += String.Format("\\{0} - {1}{2} - {3}.{4}", s.Name, s.Season, (s.Episode < 10 ? "x0" : "x") + s.Episode, s.Title, s.Extension); } //destinationPath += '\\' + s.Name + " - " + s.Season + (s.Episode < 10 ? "x0" : "x") + s.Episode + " - " + s.Title + "." + s.Extension; s.DestinationPath = destinationPath; }
/* * private void updateKodiLibrary() * { * KodiControl kc = new KodiControl("192.168.0.101", "8080"); * kc.UpdateLibrary(); * } */ private void ShowNewSeriesMatches() { List <string> ls = newSeriesDirectoriesOrFiles.Item1; List <string> filesInDir = new List <string>(); for (int i = 0; i < ls.Count; i++) { filesInDir.AddRange(fc.GetFilesInDir(ls[i])); } ls.AddRange(newSeriesDirectoriesOrFiles.Item2); UpdateListbox(listBox1, CutPath(ls)); // TODO // // Fix here so that we don't search for sub files for the individual series files. // List <Series> s = ConvertStringToSeries(filesInDir); List <Series> u = ConvertFileToSeries(newSeriesDirectoriesOrFiles.Item2); Debug.WriteLine(u.Count); s.AddRange(u); // Test to add subtitle path to the series object foreach (var ser in s) { ser.PrintSeries(); // Count how many chars there are after the last "\" int charsToRemove = 0; for (int i = ser.CurrentPath.Length - 1; i >= 0; i--) { if (ser.CurrentPath[i] == '\\') { charsToRemove++; break; } charsToRemove++; } int count = 0; foreach (var item in setObj.IncludeList) { if (Directory.GetParent(ser.CurrentPath).ToString() == item) { count++; } } List <string> l = new List <string>(); // Cut our current path string at the end, removing as many chars as we just counted string subStartPath = ser.CurrentPath.Substring(0, ser.CurrentPath.Length - charsToRemove); if (count == 0) { // Search for sub files in the folder l = FindSubFiles(subStartPath); } // Set the correct fields if we got a subtitle if (l.Count > 0) { ser.GotSubtitle = true; // If we happen to get more than 1 result from the "FindSubFiles" method // we get the one we consider the "best" where "best" means it either contains "eng" or we get the first one ser.SubtitlePath = GetBestSubFile(l); } foreach (var i in l) { Debug.WriteLine(i); } ser.PrintSeries(); } List <HashSet <Series> > lh = new List <HashSet <Series> >(); foreach (var item in s) { HashSet <Series> h = FindMatch(tvdb, item); lh.Add(h); } foreach (var set in lh) { Debug.WriteLine("Set count: " + set.Count); if (set.Count > 0) { if (set.Count > 1) { string choice = ChoiceWindow.GetChoice(set); Debug.WriteLine(choice); foreach (var item in set) { Debug.WriteLine("Comparing: " + item.Name + " with " + choice); if (item.Name == choice) { HashSet <Series> ne = new HashSet <Series>(); SetSeriesDestinationPath(item); ne.Add(item); seriesMatchesSet.Add(ne); break; } } } else { HashSet <Series> updatedSet = new HashSet <Series>(); foreach (var item in set) { SetSeriesDestinationPath(item); updatedSet.Add(item); } seriesMatchesSet.Add(updatedSet); } Debug.WriteLine("Before move file"); foreach (var item in set) { item.PrintSeries(); } ShowMatches(set); } } }