Fixed bug with download proxy url using indexerName instead of indexerID

This commit is contained in:
unknown 2015-07-22 21:21:29 -06:00
parent 72605c64cc
commit bb10442216
3 changed files with 9 additions and 9 deletions

View File

@ -29,9 +29,9 @@ namespace Jackett.Controllers
} }
[HttpGet] [HttpGet]
public async Task<HttpResponseMessage> Call(string indexerName) public async Task<HttpResponseMessage> Call(string indexerID)
{ {
var indexer = indexerService.GetIndexer(indexerName); var indexer = indexerService.GetIndexer(indexerID);
var torznabQuery = TorznabQuery.FromHttpQuery(HttpUtility.ParseQueryString(Request.RequestUri.Query)); var torznabQuery = TorznabQuery.FromHttpQuery(HttpUtility.ParseQueryString(Request.RequestUri.Query));
if (string.Equals(torznabQuery.QueryType, "caps", StringComparison.InvariantCultureIgnoreCase)) if (string.Equals(torznabQuery.QueryType, "caps", StringComparison.InvariantCultureIgnoreCase))
@ -70,7 +70,7 @@ namespace Jackett.Controllers
continue; continue;
var originalLink = release.Link; var originalLink = release.Link;
var encodedLink = HttpServerUtility.UrlTokenEncode(Encoding.UTF8.GetBytes(originalLink.ToString())) + "/download.torrent"; var encodedLink = HttpServerUtility.UrlTokenEncode(Encoding.UTF8.GetBytes(originalLink.ToString())) + "/download.torrent";
var proxyLink = string.Format("{0}api/{1}/download/{2}", severUrl, indexer.DisplayName, encodedLink); var proxyLink = string.Format("{0}api/{1}/download/{2}", severUrl, indexer.ID, encodedLink);
release.Link = new Uri(proxyLink); release.Link = new Uri(proxyLink);
} }

View File

@ -26,11 +26,11 @@ namespace Jackett.Controllers
} }
[HttpGet] [HttpGet]
public async Task<HttpResponseMessage> Download(string indexerName, string path) public async Task<HttpResponseMessage> Download(string indexerID, string path)
{ {
try try
{ {
var indexer = indexerService.GetIndexer(indexerName); var indexer = indexerService.GetIndexer(indexerID);
var remoteFile = Encoding.UTF8.GetString(HttpServerUtility.UrlTokenDecode(path)); var remoteFile = Encoding.UTF8.GetString(HttpServerUtility.UrlTokenDecode(path));
var downloadBytes = await indexer.Download(new Uri(remoteFile)); var downloadBytes = await indexer.Download(new Uri(remoteFile));
@ -41,7 +41,7 @@ namespace Jackett.Controllers
} }
catch (Exception e) catch (Exception e)
{ {
logger.Error(e, "Error downloading " + indexerName + " " + path); logger.Error(e, "Error downloading " + indexerID + " " + path);
return new HttpResponseMessage(HttpStatusCode.NotFound); return new HttpResponseMessage(HttpStatusCode.NotFound);
} }
} }

View File

@ -51,19 +51,19 @@ namespace Jackett
config.Routes.MapHttpRoute( config.Routes.MapHttpRoute(
name: "apiDefault", name: "apiDefault",
routeTemplate: "api/{indexerName}", routeTemplate: "api/{indexerID}",
defaults: new { controller = "API", action = "Call" } defaults: new { controller = "API", action = "Call" }
); );
config.Routes.MapHttpRoute( config.Routes.MapHttpRoute(
name: "api", name: "api",
routeTemplate: "api/{indexerName}/api", routeTemplate: "api/{indexerID}/api",
defaults: new { controller = "API", action = "Call" } defaults: new { controller = "API", action = "Call" }
); );
config.Routes.MapHttpRoute( config.Routes.MapHttpRoute(
name: "download", name: "download",
routeTemplate: "api/{indexerName}/download/{path}/download.torrent", routeTemplate: "api/{indexerID}/download/{path}/download.torrent",
defaults: new { controller = "Download", action = "Download" } defaults: new { controller = "Download", action = "Download" }
); );