mirror of https://github.com/Jackett/Jackett
Cardigann: add optional attribute to selectorBlock
This commit is contained in:
parent
a915d5cdec
commit
86b12837f5
|
@ -99,6 +99,7 @@ namespace Jackett.Indexers
|
||||||
public class selectorBlock
|
public class selectorBlock
|
||||||
{
|
{
|
||||||
public string Selector { get; set; }
|
public string Selector { get; set; }
|
||||||
|
public bool Optional { get; set; } = false;
|
||||||
public string Text { get; set; }
|
public string Text { get; set; }
|
||||||
public string Attribute { get; set; }
|
public string Attribute { get; set; }
|
||||||
public string Remove { get; set; }
|
public string Remove { get; set; }
|
||||||
|
@ -1271,7 +1272,7 @@ namespace Jackett.Indexers
|
||||||
{
|
{
|
||||||
if (!variables.ContainsKey(variablesKey))
|
if (!variables.ContainsKey(variablesKey))
|
||||||
variables[variablesKey] = null;
|
variables[variablesKey] = null;
|
||||||
if (OptionalFileds.Contains(Field.Key) || FieldModifiers.Contains("optional"))
|
if (OptionalFileds.Contains(Field.Key) || FieldModifiers.Contains("optional") || Field.Value.Optional)
|
||||||
continue;
|
continue;
|
||||||
throw new Exception(string.Format("Error while parsing field={0}, selector={1}, value={2}: {3}", Field.Key, Field.Value.Selector, (value == null ? "<null>" : value), ex.Message));
|
throw new Exception(string.Format("Error while parsing field={0}, selector={1}, value={2}: {3}", Field.Key, Field.Value.Selector, (value == null ? "<null>" : value), ex.Message));
|
||||||
}
|
}
|
||||||
|
@ -1315,7 +1316,7 @@ namespace Jackett.Indexers
|
||||||
|
|
||||||
// if DateHeaders is set go through the previous rows and look for the header selector
|
// if DateHeaders is set go through the previous rows and look for the header selector
|
||||||
var DateHeaders = Definition.Search.Rows.Dateheaders;
|
var DateHeaders = Definition.Search.Rows.Dateheaders;
|
||||||
if (release.PublishDate == null && DateHeaders != null)
|
if (release.PublishDate == DateTime.MinValue && DateHeaders != null)
|
||||||
{
|
{
|
||||||
var PrevRow = Row.PreviousElementSibling;
|
var PrevRow = Row.PreviousElementSibling;
|
||||||
string value = null;
|
string value = null;
|
||||||
|
@ -1333,10 +1334,10 @@ namespace Jackett.Indexers
|
||||||
PrevRow = PrevRow.PreviousElementSibling;
|
PrevRow = PrevRow.PreviousElementSibling;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value == null)
|
if (value == null && DateHeaders.Optional == false)
|
||||||
throw new Exception(string.Format("No date header row found for {0}", release.ToString()));
|
throw new Exception(string.Format("No date header row found for {0}", release.ToString()));
|
||||||
|
if (value != null)
|
||||||
release.PublishDate = DateTimeUtil.FromUnknown(value);
|
release.PublishDate = DateTimeUtil.FromUnknown(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
releases.Add(release);
|
releases.Add(release);
|
||||||
|
|
Loading…
Reference in New Issue