Your ROOT_URL in app.ini is https://git.cloudchain.link/ but you are visiting https://dash.bss.nz/open-source-mirrors/Prowlarr/commit/fedebca5e1c5178e76bf8ef8d52705b1d1890fee You should set ROOT_URL correctly, otherwise the web may not work correctly.

New: (Cardigann) Optional login selectorinputs and getselectorinputs

pull/2168/head
Bogdan 10 months ago
parent e2ce6437e9
commit fedebca5e1

@ -139,20 +139,13 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
{
var selectorSelector = ApplyGoTemplateText(selector.Selector, variables);
if (dom.Matches(selectorSelector))
{
selection = dom;
}
else
{
selection = QuerySelector(dom, selectorSelector);
}
selection = dom.Matches(selectorSelector) ? dom : QuerySelector(dom, selectorSelector);
if (selection == null)
{
if (required)
{
throw new Exception(string.Format("Selector \"{0}\" didn't match {1}", selectorSelector, dom.ToHtmlPretty()));
throw new Exception($"Selector \"{selectorSelector}\" didn't match {dom.ToHtmlPretty()}");
}
return null;
@ -195,7 +188,7 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
{
if (required)
{
throw new Exception(string.Format("Attribute \"{0}\" is not set for element {1}", selector.Attribute, selection.ToHtmlPretty()));
throw new Exception($"Attribute \"{selector.Attribute}\" is not set for element {selection.ToHtmlPretty()}");
}
return null;

@ -332,37 +332,47 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
}
// selector inputs
if (login.Selectorinputs != null)
if (login.Selectorinputs != null && login.Selectorinputs.Any())
{
foreach (var selectorinput in login.Selectorinputs)
foreach (var selectorInput in login.Selectorinputs)
{
string value = null;
try
{
value = HandleSelector(selectorinput.Value, landingResultDocument.FirstElementChild);
pairs[selectorinput.Key] = value;
var value = HandleSelector(selectorInput.Value, landingResultDocument.FirstElementChild, required: !selectorInput.Value.Optional);
if (selectorInput.Value.Optional && value == null)
{
continue;
}
pairs[selectorInput.Key] = value;
}
catch (Exception ex)
{
throw new CardigannException(string.Format("Error while parsing selector input={0}, selector={1}, value={2}: {3}", selectorinput.Key, selectorinput.Value.Selector, value, ex.Message));
throw new CardigannException($"Error while parsing selector input={selectorInput.Key}, selector={selectorInput.Value.Selector}: {ex.Message}", ex);
}
}
}
// getselector inputs
if (login.Getselectorinputs != null)
if (login.Getselectorinputs != null && login.Getselectorinputs.Any())
{
foreach (var selectorinput in login.Getselectorinputs)
foreach (var selectorInput in login.Getselectorinputs)
{
string value = null;
try
{
value = HandleSelector(selectorinput.Value, landingResultDocument.FirstElementChild);
queryCollection[selectorinput.Key] = value;
var value = HandleSelector(selectorInput.Value, landingResultDocument.FirstElementChild, required: !selectorInput.Value.Optional);
if (selectorInput.Value.Optional && value == null)
{
continue;
}
queryCollection[selectorInput.Key] = value;
}
catch (Exception ex)
{
throw new CardigannException(string.Format("Error while parsing get selector input={0}, selector={1}, value={2}: {3}", selectorinput.Key, selectorinput.Value.Selector, value, ex.Message));
throw new CardigannException($"Error while parsing get selector input={selectorInput.Key}, selector={selectorInput.Value.Selector}: {ex.Message}", ex);
}
}
}

Loading…
Cancel
Save