mirror of
https://github.com/Jackett/Jackett.git
synced 2025-10-03 00:47:21 +02:00
Cardigann: Add support for :root pseudo selector
This commit is contained in:
@@ -606,6 +606,20 @@ namespace Jackett.Indexers
|
|||||||
return Data;
|
return Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IElement QuerySelector(IElement Element, string Selector)
|
||||||
|
{
|
||||||
|
// AngleSharp doesn't support the :root pseudo selector, so we check for it manually
|
||||||
|
if (Selector.StartsWith(":root"))
|
||||||
|
{
|
||||||
|
Selector = Selector.Substring(5);
|
||||||
|
while (Element.ParentElement != null)
|
||||||
|
{
|
||||||
|
Element = Element.ParentElement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Element.QuerySelector(Selector);
|
||||||
|
}
|
||||||
|
|
||||||
protected string handleSelector(selectorBlock Selector, IElement Dom)
|
protected string handleSelector(selectorBlock Selector, IElement Dom)
|
||||||
{
|
{
|
||||||
if (Selector.Text != null)
|
if (Selector.Text != null)
|
||||||
@@ -618,7 +632,7 @@ namespace Jackett.Indexers
|
|||||||
|
|
||||||
if (Selector.Selector != null)
|
if (Selector.Selector != null)
|
||||||
{
|
{
|
||||||
selection = Dom.QuerySelector(Selector.Selector);
|
selection = QuerySelector(Dom, Selector.Selector);
|
||||||
if (selection == null)
|
if (selection == null)
|
||||||
{
|
{
|
||||||
throw new Exception(string.Format("Selector \"{0}\" didn't match {1}", Selector.Selector, Dom.OuterHtml));
|
throw new Exception(string.Format("Selector \"{0}\" didn't match {1}", Selector.Selector, Dom.OuterHtml));
|
||||||
@@ -637,7 +651,7 @@ namespace Jackett.Indexers
|
|||||||
{
|
{
|
||||||
foreach(var Case in Selector.Case)
|
foreach(var Case in Selector.Case)
|
||||||
{
|
{
|
||||||
if (selection.Matches(Case.Key) || selection.QuerySelector(Case.Key) != null)
|
if (selection.Matches(Case.Key) || QuerySelector(selection, Case.Key) != null)
|
||||||
{
|
{
|
||||||
value = Case.Value;
|
value = Case.Value;
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user