mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Changed download urls
I changed the download urls, because the current way with segments (having the parameters between slashes) was causing problems with long encoded urls, since a segment can be no longer than 255 characters. It was changed to use regular url parameters which have no such limit on length.
This commit is contained in:
@@ -425,7 +425,7 @@ namespace Jackett.Controllers
|
||||
foreach (var result in results)
|
||||
{
|
||||
var link = result.Link;
|
||||
result.Link = serverService.ConvertToProxyLink(link, serverUrl, result.TrackerId);
|
||||
result.Link = serverService.ConvertToProxyLink(link, serverUrl, result.TrackerId, "dl", result.Title + ".torrent");
|
||||
if (result.Link != null && result.Link.Scheme != "magnet" && !string.IsNullOrWhiteSpace(Engine.Server.Config.BlackholeDir))
|
||||
result.BlackholeLink = serverService.ConvertToProxyLink(link, serverUrl, result.TrackerId, "bh", string.Empty);
|
||||
|
||||
|
@@ -29,7 +29,7 @@ namespace Jackett.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<HttpResponseMessage> Download(string indexerID, string path, string apikey)
|
||||
public async Task<HttpResponseMessage> Download(string indexerID, string path, string apikey, string file)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -54,6 +54,10 @@ namespace Jackett.Controllers
|
||||
var result = new HttpResponseMessage(HttpStatusCode.OK);
|
||||
result.Content = new ByteArrayContent(downloadBytes);
|
||||
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-bittorrent");
|
||||
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
|
||||
{
|
||||
FileName = file
|
||||
};
|
||||
return result;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@@ -126,7 +126,7 @@ namespace Jackett.Controllers
|
||||
foreach (var r in releases)
|
||||
{
|
||||
var release = Mapper.Map<ReleaseInfo>(r);
|
||||
release.Link = serverService.ConvertToProxyLink(release.Link, serverUrl, indexerID);
|
||||
release.Link = serverService.ConvertToProxyLink(release.Link, serverUrl, indexerID, "dl", release.Title + ".torrent");
|
||||
|
||||
// Only accept torrent links, magnet is not supported
|
||||
if (release.Link != null)
|
||||
|
@@ -116,7 +116,7 @@ namespace Jackett.Controllers
|
||||
foreach(var result in releases)
|
||||
{
|
||||
var clone = Mapper.Map<ReleaseInfo>(result);
|
||||
clone.Link = serverService.ConvertToProxyLink(clone.Link, serverUrl, indexerID);
|
||||
clone.Link = serverService.ConvertToProxyLink(clone.Link, serverUrl, indexerID, "dl", result.Title + ".torrent");
|
||||
resultPage.Releases.Add(clone);
|
||||
}
|
||||
|
||||
|
@@ -168,6 +168,27 @@ namespace Jackett.Indexers
|
||||
episodeSearchUrl = $"{SearchUrl}?page={page}&group=0&{catsUrlPart}&search={HttpUtility.UrlEncode(query.GetQueryString())}&pre_type=torrents&type=";
|
||||
}
|
||||
var results = await RequestStringWithCookiesAndRetry(episodeSearchUrl);
|
||||
if (string.IsNullOrEmpty(results.Content))
|
||||
{
|
||||
CookieHeader = string.Empty;
|
||||
var pairs = new Dictionary<string, string>
|
||||
{
|
||||
{"username", configData.Username.Value},
|
||||
{"password", configData.Password.Value},
|
||||
{"langlang", null},
|
||||
{"login", "login"}
|
||||
};
|
||||
var response = await RequestLoginAndFollowRedirect(LoginUrl, pairs, CookieHeader, true, null, LoginUrl);
|
||||
|
||||
await ConfigureIfOK(response.Cookies, response.Content != null && response.Content.Contains("logout.php"), () =>
|
||||
{
|
||||
CQ dom = response.Content;
|
||||
var messageEl = dom["#loginform .warning"];
|
||||
var errorMessage = messageEl.Text().Trim();
|
||||
throw new ExceptionWithConfigData(errorMessage, configData);
|
||||
});
|
||||
results = await RequestStringWithCookiesAndRetry(episodeSearchUrl);
|
||||
}
|
||||
try
|
||||
{
|
||||
CQ dom = results.Content;
|
||||
@@ -206,14 +227,17 @@ namespace Jackett.Indexers
|
||||
else
|
||||
continue;
|
||||
|
||||
var dlUrlAnchor = qRow.Find("span.right a").FirstElement();
|
||||
var dlUrl = dlUrlAnchor.GetAttribute("href");
|
||||
release.Link = new Uri(SiteLink + dlUrl);
|
||||
|
||||
var titleAnchor = qRow.Find("div.croptorrenttext a").FirstElement();
|
||||
var title = titleAnchor.GetAttribute("title");
|
||||
release.Title = title;
|
||||
|
||||
var dlUrlAnchor = qRow.Find("span.right a").FirstElement();
|
||||
var dlUrl = dlUrlAnchor.GetAttribute("href");
|
||||
var authkey = Regex.Match(dlUrl, "authkey=(?<authkey>[0-9a-zA-Z]+)").Groups["authkey"].Value;
|
||||
var torrentPass = Regex.Match(dlUrl, "torrent_pass=(?<torrent_pass>[0-9a-zA-Z]+)").Groups["torrent_pass"].Value;
|
||||
var torrentId = Regex.Match(dlUrl, "id=(?<id>[0-9]+)").Groups["id"].Value;
|
||||
release.Link = new Uri($"{SearchUrl}/{title}.torrent/?action=download&authkey={authkey}&torrent_pass={torrentPass}&id={torrentId}");
|
||||
|
||||
var torrentLink = titleAnchor.GetAttribute("href");
|
||||
release.Guid = new Uri(SiteLink + torrentLink);
|
||||
release.Comments = new Uri(SearchUrl + torrentLink);
|
||||
|
@@ -438,6 +438,7 @@
|
||||
<Content Include="Content\logos\broadcastthenet.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\logos\danishbits.PNG" />
|
||||
<Content Include="Content\logos\demonoid.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
@@ -32,7 +32,7 @@ namespace Jackett.Services
|
||||
void ReserveUrls(bool doInstall = true);
|
||||
ServerConfig Config { get; }
|
||||
void SaveConfig();
|
||||
Uri ConvertToProxyLink(Uri link, string serverUrl, string indexerId, string action = "dl", string file = "/t.torrent");
|
||||
Uri ConvertToProxyLink(Uri link, string serverUrl, string indexerId, string action = "dl", string file = "t.torrent");
|
||||
}
|
||||
|
||||
public class ServerService : IServerService
|
||||
@@ -65,13 +65,13 @@ namespace Jackett.Services
|
||||
get { return config; }
|
||||
}
|
||||
|
||||
public Uri ConvertToProxyLink(Uri link, string serverUrl, string indexerId, string action = "dl", string file = "/t.torrent")
|
||||
public Uri ConvertToProxyLink(Uri link, string serverUrl, string indexerId, string action = "dl", string file = "t.torrent")
|
||||
{
|
||||
if (link == null || (link.IsAbsoluteUri && link.Scheme == "magnet"))
|
||||
return link;
|
||||
|
||||
var encodedLink = HttpServerUtility.UrlTokenEncode(Encoding.UTF8.GetBytes(link.ToString())) + file;
|
||||
var proxyLink = string.Format("{0}{1}/{2}/{3}/{4}", serverUrl, action, indexerId, config.APIKey, encodedLink);
|
||||
var encodedLink = HttpServerUtility.UrlTokenEncode(Encoding.UTF8.GetBytes(link.ToString()));
|
||||
var proxyLink = string.Format("{0}{1}/{2}/{3}?path={4}&file={5}", serverUrl, action, indexerId, config.APIKey, encodedLink, file);
|
||||
return new Uri(proxyLink);
|
||||
}
|
||||
|
||||
|
@@ -111,7 +111,7 @@ namespace Jackett
|
||||
|
||||
config.Routes.MapHttpRoute(
|
||||
name: "download",
|
||||
routeTemplate: "dl/{indexerID}/{apikey}/{path}/t.torrent",
|
||||
routeTemplate: "dl/{indexerID}/{apiKey}",
|
||||
defaults: new { controller = "Download", action = "Download" }
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user