Category mapping on TorrentLeech and AnimeBytes. Fix sparadic issue where downloads fail due to the url being too long.

This commit is contained in:
KZ
2015-08-13 22:51:49 +01:00
parent 3c0cae7166
commit e660c57ccb
20 changed files with 222 additions and 60 deletions

View File

@@ -20,6 +20,7 @@ using System.Net.NetworkInformation;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace Jackett.Services
{
@@ -31,6 +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");
}
public class ServerService : IServerService
@@ -63,6 +65,16 @@ namespace Jackett.Services
get { return config; }
}
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);
return new Uri(proxyLink);
}
private void LoadConfig()
{
// Load config