Fixed: Grab from Search page

pull/25/head
Qstick 4 years ago
parent b41c911092
commit 6d25b468ce

@ -27,5 +27,6 @@ namespace NzbDrone.Core.IndexerSearch
public string title { get; set; }
public string configured { get; set; }
public string source { get; set; }
public string server { get; set; }
}
}

@ -22,21 +22,22 @@ namespace NzbDrone.Core.IndexerSearch
{
private readonly IEventAggregator _eventAggregator;
private readonly IIndexerFactory _indexerFactory;
private readonly IDownloadMappingService _downloadMappingService;
private readonly Logger _logger;
public NzbSearchService(IEventAggregator eventAggregator,
IIndexerFactory indexerFactory,
IDownloadMappingService downloadMappingService,
Logger logger)
{
_eventAggregator = eventAggregator;
_indexerFactory = indexerFactory;
_downloadMappingService = downloadMappingService;
_logger = logger;
}
public NewznabResults Search(NewznabRequest request, List<int> indexerIds, bool interactiveSearch)
{
var results = new NewznabResults();
switch (request.t)
{
case "movie":
@ -60,7 +61,7 @@ namespace NzbDrone.Core.IndexerSearch
searchSpec.TmdbId = request.tmdbid;
searchSpec.TraktId = request.traktid;
return new NewznabResults { Releases = Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec) };
return new NewznabResults { Releases = MapReleases(Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec), request.server) };
}
private NewznabResults MusicSearch(NewznabRequest request, List<int> indexerIds, bool interactiveSearch)
@ -71,7 +72,7 @@ namespace NzbDrone.Core.IndexerSearch
searchSpec.Album = request.album;
searchSpec.Label = request.label;
return new NewznabResults { Releases = Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec) };
return new NewznabResults { Releases = MapReleases(Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec), request.server) };
}
private NewznabResults TvSearch(NewznabRequest request, List<int> indexerIds, bool interactiveSearch)
@ -86,7 +87,7 @@ namespace NzbDrone.Core.IndexerSearch
searchSpec.RId = request.rid;
searchSpec.TvMazeId = request.tvmazeid;
return new NewznabResults { Releases = Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec) };
return new NewznabResults { Releases = MapReleases(Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec), request.server) };
}
private NewznabResults BookSearch(NewznabRequest request, List<int> indexerIds, bool interactiveSearch)
@ -96,14 +97,24 @@ namespace NzbDrone.Core.IndexerSearch
searchSpec.Author = request.author;
searchSpec.Title = request.title;
return new NewznabResults { Releases = Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec) };
return new NewznabResults { Releases = MapReleases(Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec), request.server) };
}
private NewznabResults BasicSearch(NewznabRequest request, List<int> indexerIds, bool interactiveSearch)
{
var searchSpec = Get<BasicSearchCriteria>(request, indexerIds, interactiveSearch);
return new NewznabResults { Releases = Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec) };
return new NewznabResults { Releases = MapReleases(Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec), request.server) };
}
private List<ReleaseInfo> MapReleases(List<ReleaseInfo> releases, string serverUrl)
{
foreach (var result in releases)
{
result.DownloadUrl = _downloadMappingService.ConvertToProxyLink(new Uri(result.DownloadUrl), serverUrl, result.IndexerId, result.Title).ToString();
}
return releases;
}
private TSpec Get<TSpec>(NewznabRequest query, List<int> indexerIds, bool interactiveSearch)

@ -54,6 +54,7 @@ namespace Prowlarr.Api.V1.Indexers
{
var requestType = request.t;
request.source = UserAgentParser.ParseSource(Request.Headers.UserAgent);
request.server = Request.GetServerUrl();
if (requestType.IsNullOrWhiteSpace())
{
@ -68,7 +69,6 @@ namespace Prowlarr.Api.V1.Indexers
}
var indexerInstance = _indexerFactory.GetInstance(indexer);
var serverUrl = Request.GetServerUrl();
switch (requestType)
{
@ -83,11 +83,6 @@ namespace Prowlarr.Api.V1.Indexers
case "movie":
var results = _nzbSearchService.Search(request, new List<int> { indexer.Id }, false);
foreach (var result in results.Releases)
{
result.DownloadUrl = _downloadMappingService.ConvertToProxyLink(new Uri(result.DownloadUrl), serverUrl, indexer.Id, result.Title).ToString();
}
Response searchResponse = results.ToXml(indexerInstance.Protocol);
searchResponse.ContentType = "application/rss+xml";
return searchResponse;

@ -9,6 +9,7 @@ using NzbDrone.Core.IndexerSearch;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
using Prowlarr.Http;
using Prowlarr.Http.Extensions;
namespace Prowlarr.Api.V1.Search
{
@ -51,7 +52,8 @@ namespace Prowlarr.Api.V1.Search
{
try
{
var decisions = _nzbSearhService.Search(new NewznabRequest { q = query, source = "Prowlarr", t = "search", cat = string.Join(",", categories) }, indexerIds, true).Releases;
var request = new NewznabRequest { q = query, source = "Prowlarr", t = "search", cat = string.Join(",", categories), server = Request.GetServerUrl() };
var decisions = _nzbSearhService.Search(request, indexerIds, true).Releases;
return MapDecisions(decisions);
}

Loading…
Cancel
Save