private void MapCardigannDefinition(IndexerDefinition definition) { var settings = (CardigannSettings)definition.Settings; var defFile = _definitionService.GetCachedDefinition(settings.DefinitionFile); definition.ExtraFields = defFile.Settings; if (defFile.Login?.Captcha != null && !definition.ExtraFields.Any(x => x.Type == "cardigannCaptcha")) { definition.ExtraFields.Add(new SettingsField { Name = "cardigannCaptcha", Type = "cardigannCaptcha", Label = "CAPTCHA" }); } definition.IndexerUrls = defFile.Links.ToArray(); definition.Description = defFile.Description; definition.Language = defFile.Language; definition.Encoding = Encoding.GetEncoding(defFile.Encoding); definition.Privacy = defFile.Type switch { "private" => IndexerPrivacy.Private, "public" => IndexerPrivacy.Public, _ => IndexerPrivacy.SemiPrivate }; definition.Capabilities = new IndexerCapabilities(); definition.Capabilities.ParseCardigannSearchModes(defFile.Caps.Modes); definition.Capabilities.SupportsRawSearch = defFile.Caps.Allowrawsearch; MapCardigannCategories(definition, defFile); }
public override IIndexerRequestGenerator GetRequestGenerator() { var generator = _generatorCache.Get(Settings.DefinitionFile, () => new CardigannRequestGenerator(_configService, _definitionService.GetCachedDefinition(Settings.DefinitionFile), _logger) { HttpClient = _httpClient, Definition = Definition, Settings = Settings }); generator = (CardigannRequestGenerator)SetCookieFunctions(generator); generator.Settings = Settings; _generatorCache.ClearExpired(); return(generator); }
public override IndexerDefinition ToModel(IndexerResource resource) { if (resource == null) { return(null); } var definition = base.ToModel(resource); if (resource.Implementation == typeof(Cardigann).Name) { var standardFields = base.ToResource(definition).Fields.Select(x => x.Name).ToList(); var settings = (CardigannSettings)definition.Settings; var cardigannDefinition = _definitionService.GetCachedDefinition(settings.DefinitionFile); foreach (var field in resource.Fields) { if (!standardFields.Contains(field.Name)) { if (field.Name == "cardigannCaptcha") { settings.ExtraFieldData["CAPTCHA"] = field.Value?.ToString() ?? string.Empty; } else { var cardigannSetting = cardigannDefinition.Settings.FirstOrDefault(x => x.Name == field.Name); settings.ExtraFieldData[field.Name] = MapValue(cardigannSetting, field.Value); } } } } definition.AppProfileId = resource.AppProfileId; definition.Enable = resource.Enable; definition.Redirect = resource.Redirect; definition.IndexerUrls = resource.IndexerUrls; definition.Priority = resource.Priority; definition.Privacy = resource.Privacy; definition.Added = resource.Added; return(definition); }