Fixed: (SceneTime) Add search by imdbid

pull/1519/head
Bogdan 2 years ago
parent e211436eb5
commit 577477c42d

@ -37,7 +37,7 @@ namespace NzbDrone.Core.Indexers.Definitions
public override IIndexerRequestGenerator GetRequestGenerator() public override IIndexerRequestGenerator GetRequestGenerator()
{ {
return new SceneTimeRequestGenerator { Settings = Settings, Capabilities = Capabilities }; return new SceneTimeRequestGenerator(Settings, Capabilities);
} }
public override IParseIndexerResponse GetParser() public override IParseIndexerResponse GetParser()
@ -66,11 +66,11 @@ namespace NzbDrone.Core.Indexers.Definitions
{ {
TvSearchParams = new List<TvSearchParam> TvSearchParams = new List<TvSearchParam>
{ {
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep, TvSearchParam.ImdbId
}, },
MovieSearchParams = new List<MovieSearchParam> MovieSearchParams = new List<MovieSearchParam>
{ {
MovieSearchParam.Q MovieSearchParam.Q, MovieSearchParam.ImdbId
}, },
MusicSearchParams = new List<MusicSearchParam> MusicSearchParams = new List<MusicSearchParam>
{ {
@ -118,63 +118,38 @@ namespace NzbDrone.Core.Indexers.Definitions
public class SceneTimeRequestGenerator : IIndexerRequestGenerator public class SceneTimeRequestGenerator : IIndexerRequestGenerator
{ {
public SceneTimeSettings Settings { get; set; } private readonly SceneTimeSettings _settings;
public IndexerCapabilities Capabilities { get; set; } private readonly IndexerCapabilities _capabilities;
private IEnumerable<IndexerRequest> GetPagedRequests(string term, int[] categories) public SceneTimeRequestGenerator(SceneTimeSettings settings, IndexerCapabilities capabilities)
{ {
var qc = new NameValueCollection _settings = settings;
{ _capabilities = capabilities;
{ "cata", "yes" },
{ "sec", "jax" }
};
var catList = Capabilities.Categories.MapTorznabCapsToTrackers(categories);
foreach (var cat in catList)
{
qc.Set($"c{cat}", "1");
}
if (term.IsNotNullOrWhiteSpace())
{
qc.Set("search", term);
}
if (Settings.FreeLeechOnly)
{
qc.Set("freeleech", "on");
}
var searchUrl = $"{Settings.BaseUrl.TrimEnd('/')}/browse.php?{qc.GetQueryString()}";
var request = new IndexerRequest(searchUrl, HttpAccept.Html);
yield return request;
} }
public IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria) public IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria)
{ {
var pageableRequests = new IndexerPageableRequestChain(); var pageableRequests = new IndexerPageableRequestChain();
pageableRequests.Add(GetPagedRequests(string.Format("{0}", searchCriteria.SanitizedSearchTerm), searchCriteria.Categories)); pageableRequests.Add(GetPagedRequests($"{searchCriteria.SanitizedSearchTerm}", searchCriteria.Categories, searchCriteria.FullImdbId));
return pageableRequests; return pageableRequests;
} }
public IndexerPageableRequestChain GetSearchRequests(MusicSearchCriteria searchCriteria) public IndexerPageableRequestChain GetSearchRequests(TvSearchCriteria searchCriteria)
{ {
var pageableRequests = new IndexerPageableRequestChain(); var pageableRequests = new IndexerPageableRequestChain();
pageableRequests.Add(GetPagedRequests(string.Format("{0}", searchCriteria.SanitizedSearchTerm), searchCriteria.Categories)); pageableRequests.Add(GetPagedRequests($"{searchCriteria.SanitizedTvSearchString}", searchCriteria.Categories, searchCriteria.FullImdbId));
return pageableRequests; return pageableRequests;
} }
public IndexerPageableRequestChain GetSearchRequests(TvSearchCriteria searchCriteria) public IndexerPageableRequestChain GetSearchRequests(MusicSearchCriteria searchCriteria)
{ {
var pageableRequests = new IndexerPageableRequestChain(); var pageableRequests = new IndexerPageableRequestChain();
pageableRequests.Add(GetPagedRequests(string.Format("{0}", searchCriteria.SanitizedTvSearchString), searchCriteria.Categories)); pageableRequests.Add(GetPagedRequests($"{searchCriteria.SanitizedSearchTerm}", searchCriteria.Categories));
return pageableRequests; return pageableRequests;
} }
@ -183,7 +158,7 @@ namespace NzbDrone.Core.Indexers.Definitions
{ {
var pageableRequests = new IndexerPageableRequestChain(); var pageableRequests = new IndexerPageableRequestChain();
pageableRequests.Add(GetPagedRequests(string.Format("{0}", searchCriteria.SanitizedSearchTerm), searchCriteria.Categories)); pageableRequests.Add(GetPagedRequests($"{searchCriteria.SanitizedSearchTerm}", searchCriteria.Categories));
return pageableRequests; return pageableRequests;
} }
@ -192,11 +167,44 @@ namespace NzbDrone.Core.Indexers.Definitions
{ {
var pageableRequests = new IndexerPageableRequestChain(); var pageableRequests = new IndexerPageableRequestChain();
pageableRequests.Add(GetPagedRequests(string.Format("{0}", searchCriteria.SanitizedSearchTerm), searchCriteria.Categories)); pageableRequests.Add(GetPagedRequests($"{searchCriteria.SanitizedSearchTerm}", searchCriteria.Categories));
return pageableRequests; return pageableRequests;
} }
private IEnumerable<IndexerRequest> GetPagedRequests(string term, int[] categories, string imdbId = null)
{
var parameters = new NameValueCollection
{
{ "cata", "yes" }
};
var catList = _capabilities.Categories.MapTorznabCapsToTrackers(categories);
foreach (var cat in catList)
{
parameters.Set($"c{cat}", "1");
}
if (imdbId.IsNotNullOrWhiteSpace())
{
parameters.Set("imdb", imdbId);
}
if (term.IsNotNullOrWhiteSpace())
{
parameters.Set("search", term);
}
if (_settings.FreeLeechOnly)
{
parameters.Set("freeleech", "on");
}
var searchUrl = $"{_settings.BaseUrl.TrimEnd('/')}/browse.php?{parameters.GetQueryString()}";
yield return new IndexerRequest(searchUrl, HttpAccept.Html);
}
public Func<IDictionary<string, string>> GetCookies { get; set; } public Func<IDictionary<string, string>> GetCookies { get; set; }
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; } public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
} }
@ -225,8 +233,7 @@ namespace NzbDrone.Core.Indexers.Definitions
return releaseInfos; // no results return releaseInfos; // no results
} }
var headerColumns = table.QuerySelectorAll("tbody > tr > td.cat_Head") var headerColumns = table.QuerySelectorAll("tbody > tr > td.cat_Head").Select(x => x.TextContent).ToList();
.Select(x => x.TextContent).ToList();
var categoryIndex = headerColumns.FindIndex(x => x.Equals("Type")); var categoryIndex = headerColumns.FindIndex(x => x.Equals("Type"));
var nameIndex = headerColumns.FindIndex(x => x.Equals("Name")); var nameIndex = headerColumns.FindIndex(x => x.Equals("Name"));
var sizeIndex = headerColumns.FindIndex(x => x.Equals("Size")); var sizeIndex = headerColumns.FindIndex(x => x.Equals("Size"));
@ -287,7 +294,7 @@ namespace NzbDrone.Core.Indexers.Definitions
public class SceneTimeSettings : CookieTorrentBaseSettings public class SceneTimeSettings : CookieTorrentBaseSettings
{ {
[FieldDefinition(3, Label = "FreeLeech Only", Type = FieldType.Checkbox, HelpText = "Search Freeleech torrents only")] [FieldDefinition(3, Label = "FreeLeech Only", Type = FieldType.Checkbox, HelpText = "Search FreeLeech torrents only")]
public bool FreeLeechOnly { get; set; } public bool FreeLeechOnly { get; set; }
} }
} }

Loading…
Cancel
Save