public List <MagnetSource> GetSearchSources() { List <MagnetSource> searchSources = new List <MagnetSource>(); foreach (string source in SearchSources.Split(",")) { if (Enum.TryParse(source, true, out MagnetSource magnetSource)) { searchSources.Add(magnetSource); } } return(searchSources); }
public TabControl RenderizeSeasonTab(string lastSeasonUrl, SearchSources sourceName) { HtmlAgilityPack.HtmlDocument htmldoc = _web.LoadFromBrowser(lastSeasonUrl); List <ISourceScraperData> scraperData = new List <ISourceScraperData>(); IEnumerable <HtmlNode> episodes; switch (sourceName) { case SearchSources.TuSubtitulo: episodes = htmldoc.DocumentNode.Descendants("table").Skip(1); foreach (HtmlNode episode in episodes) { TuSubtituloScraperData scraperItem = new TuSubtituloScraperData(); scraperItem.SetEpisodeData(episode, "https:"); scraperData.Add(scraperItem); } break; case SearchSources.Subtitulamos: HtmlNode episodesWrapper = htmldoc.DocumentNode.Descendants("div").SingleOrDefault(x => x.Id == "episode-choices"); episodes = episodesWrapper.Descendants("a"); foreach (HtmlNode episode in episodes) { HtmlAgilityPack.HtmlDocument episodeHtml = _web.Load("https://www.subtitulamos.tv" + episode.Attributes["href"].Value); SubtitulamosScraperData scraperItem = new SubtitulamosScraperData(); scraperItem.SetEpisodeData(episodeHtml.DocumentNode.Descendants("div").SingleOrDefault(e => e.Attributes.Contains("class") && e.Attributes["class"].Value.Equals("content limited-width")), "https://www.subtitulamos.tv"); scraperData.Add(scraperItem); } break; default: MessageBox.Show("No se pudo generar los resultados. El servidor de datos para la búsqueda es incorrecta."); break; } _sourceName = sourceName; _TabCtrlResults = SetControls(scraperData, _TabCtrlResults); return(_TabCtrlResults); }
public ActionResult Search(SearchBox model) { if (!model.ShowFreeDocuments.HasValue) { model.ShowFreeDocuments = this.UserData.ShowFreeDocuments; } try { SearchSources searchSource = SearchSources.Search; if (model.ClassifierFilter != null) { searchSource = SearchSources.Classifier; } else if (model.DocInLinks != null) { searchSource = SearchSources.InLinks; } else if (model.HomeSearch != null) { searchSource = SearchSources.HomePage; } string searchWrapperUrl = null; if (ConfigurationManager.AppSettings["SolutionVersion"] == "product") { searchWrapperUrl = ConfigurationManager.AppSettings["SearchWrapper_BasePath"]; } else { searchWrapperUrl = ConfigurationManager.AppSettings["SearchWrapper_BasePath_cc"]; } //if (searchSource == SearchSources.Search) //{ // if ((model.Cases != null && model.Cases.TranslateSearchText) || // (model.Law != null && model.Law.TranslateSearchText)) // { // string textLang = // model.SearchTextMultiLingual = (new BanTranslateService()).Translate(model.SearchText, "bg", "en"); // } //} SearchResult sr = new SearchResult(searchSource, HttpContext.Application["SearchWrapper"], searchWrapperUrl, HttpContext.Application["FilterDocsStruct"], HttpContext.Application["FilterDocsClassifiers"], HttpContext.Application["ClassifiersMap"], HttpContext.Application["ResultsGroupper"], HttpRuntime.AppDomainAppPath, this.Language.Id, pageSize, visiblePagesCount); // searchbox model passing sr.SearchBoxFilters = model; // passing current product int curProductId = 1; if (Session["SelectedProductId"] != null) { curProductId = int.Parse(Session["SelectedProductId"].ToString()); } sr.ProductId = curProductId; //sr.DisplayContext = true; if (model.HomeSearch != null) { if (model.HasRelSort) { sr.SortBy = "rel"; sr.SortDir = "asc"; } else { sr.SortBy = "date"; sr.SortDir = "desc"; } } int?searchId = SearchResult.AddSearchResult(sr, Session["SearchResults"]); Session["search-global-" + sr.SearchBoxFilters.GlobalId] = searchId; if (Request.IsAjaxRequest()) { if (searchId.HasValue) { return(Json(new { result = "Redirect", url = Url.Action("List", "Search", new { searchId = searchId }) })); } else { return(Json(new { result = "Redirect", url = Url.Action("Index", "Home") })); } } else { if (searchId.HasValue) { return(RedirectToAction("List", "Search", new { searchId = searchId })); } else { return(RedirectToAction("Index", "Home")); } } } catch (Exception e) { var logsDirectory = HttpRuntime.AppDomainAppPath; logsDirectory = logsDirectory + "Logs\\Searches\\"; var timeOfLoging = DateTime.Now; var timePathParsed = ""; timePathParsed = timePathParsed + timeOfLoging.Year + "_" + timeOfLoging.Month + "_" + timeOfLoging.Day; var fullPath = logsDirectory + timePathParsed + ".txt"; var searchDetails = "Search: " + JsonConvert.SerializeObject(model); var userId = "User: "******"Exception message: " + e.Message + Environment.NewLine + "InnerExceptionMessage: " + innerExceptionMessage + Environment.NewLine + Environment.NewLine); return(Json("Error")); } }