mirror of https://github.com/Jackett/Jackett
Cardigann: Add support for non-direct download links
This commit is contained in:
parent
9a66289a26
commit
58a7de145a
|
@ -50,6 +50,7 @@ namespace Jackett.Indexers
|
||||||
public loginBlock Login { get; set; }
|
public loginBlock Login { get; set; }
|
||||||
public ratioBlock Ratio { get; set; }
|
public ratioBlock Ratio { get; set; }
|
||||||
public searchBlock Search { get; set; }
|
public searchBlock Search { get; set; }
|
||||||
|
public downloadBlock Download { get; set; }
|
||||||
// IndexerDefinitionStats not needed/implemented
|
// IndexerDefinitionStats not needed/implemented
|
||||||
}
|
}
|
||||||
public class settingsField
|
public class settingsField
|
||||||
|
@ -124,6 +125,11 @@ namespace Jackett.Indexers
|
||||||
public selectorBlock Dateheaders { get; set; }
|
public selectorBlock Dateheaders { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class downloadBlock
|
||||||
|
{
|
||||||
|
public string Selector { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
protected readonly string[] OptionalFileds = new string[] { "imdb" };
|
protected readonly string[] OptionalFileds = new string[] { "imdb" };
|
||||||
|
|
||||||
public CardigannIndexer(IIndexerManagerService i, IWebClient wc, Logger l, IProtectionService ps)
|
public CardigannIndexer(IIndexerManagerService i, IWebClient wc, Logger l, IProtectionService ps)
|
||||||
|
@ -986,6 +992,34 @@ namespace Jackett.Indexers
|
||||||
|
|
||||||
return releases;
|
return releases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override async Task<byte[]> Download(Uri link)
|
||||||
|
{
|
||||||
|
if(Definition.Download != null)
|
||||||
|
{
|
||||||
|
var Download = Definition.Download;
|
||||||
|
if (Download.Selector != null)
|
||||||
|
{
|
||||||
|
var response = await RequestStringWithCookies(link.ToString());
|
||||||
|
var results = response.Content;
|
||||||
|
var SearchResultParser = new HtmlParser();
|
||||||
|
var SearchResultDocument = SearchResultParser.Parse(results);
|
||||||
|
var DlUri = SearchResultDocument.QuerySelector(Download.Selector);
|
||||||
|
if (DlUri != null)
|
||||||
|
{
|
||||||
|
logger.Debug(string.Format("CardigannIndexer ({0}): Download selector {1} matched:{2}", ID, Download.Selector, DlUri.OuterHtml));
|
||||||
|
var href = DlUri.GetAttribute("href");
|
||||||
|
link = resolvePath(href);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.Error(string.Format("CardigannIndexer ({0}): Download selector {1} didn't match:\n{2}", ID, Download.Selector, results));
|
||||||
|
throw new Exception(string.Format("Download selector {0} didn't match", Download.Selector));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return await base.Download(link);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue