/// <summary> /// Subtitle Search Result Parsing function. /// Extracts search results (i.e. Show names) and gets links to them. /// If more than one show is found, user gets to select one, otherwise he will be directly forwarded /// For now only pages where search links directly to subtitles work /// </summary> /// <param name="source">HTML Source of the search results page</param> /// <param name="SourceURL">URL of the source</param> private static void ParseSubtitleSearch(ref string source, string SourceURL) { if (source == "") { return; } SubtitleProvider subprovider = SubtitleProvider.GetCurrentProvider(); string pattern = subprovider.SearchRegExp; RegexOptions ro = RegexOptions.IgnoreCase | RegexOptions.Singleline; if (subprovider.SearchRightToLeft) { ro |= RegexOptions.RightToLeft; } MatchCollection mc = Regex.Matches(source, pattern, ro); if (mc.Count == 0) { log.Info("No results found"); } else if (mc.Count == 1) { string url = subprovider.SubtitlesPage; url = url.Replace("%L", mc[0].Groups["link"].Value); if (subprovider.ConstructLink != "") { ConstructLinks(mc[0].Groups["link"].Value); } else { //GetSubtitleFromSeriesPage(url); } } else { log.Info("Search engine found multiple results at " + SourceURL.Replace(" ", "%20")); SelectResult sr = new SelectResult(mc, subprovider, true); if (sr.ShowDialog() == DialogResult.Cancel) { return; } if (sr.urls.Count == 0) { return; } foreach (string str in sr.urls) { string url = subprovider.SubtitlesPage; url = url.Replace("%L", str); if (subprovider.ConstructLink != "") { ConstructLinks(str); } else { //GetSubtitleFromSeriesPage(url); } } } }
/// <summary> /// Subtitle Search Result Parsing function. /// Extracts search results (i.e. Show names) and gets links to them. /// If more than one show is found, user gets to select one, otherwise he will be directly forwarded /// For now only pages where search links directly to subtitles work /// </summary> /// <param name="source">HTML Source of the search results page</param> /// <param name="SourceURL">URL of the source</param> private static void ParseSubtitleSearch(ref string source, string SourceURL) { if (source == "") return; SubtitleProvider subprovider = SubtitleProvider.GetCurrentProvider(); string pattern = subprovider.SearchRegExp; RegexOptions ro = RegexOptions.IgnoreCase | RegexOptions.Singleline; if (subprovider.SearchRightToLeft) ro |= RegexOptions.RightToLeft; MatchCollection mc = Regex.Matches(source, pattern, ro); if (mc.Count == 0) { log.Info("No results found"); } else if (mc.Count == 1) { string url = subprovider.SubtitlesPage; url = url.Replace("%L", mc[0].Groups["link"].Value); if (subprovider.ConstructLink != "") { ConstructLinks(mc[0].Groups["link"].Value); } else { //GetSubtitleFromSeriesPage(url); } } else { log.Info("Search engine found multiple results at " + SourceURL.Replace(" ", "%20")); SelectResult sr = new SelectResult(mc, subprovider, true); if (sr.ShowDialog() == DialogResult.Cancel) return; if (sr.urls.Count == 0) return; foreach (string str in sr.urls) { string url = subprovider.SubtitlesPage; url = url.Replace("%L", str); if (subprovider.ConstructLink != "") { ConstructLinks(str); } else { //GetSubtitleFromSeriesPage(url); } } } }