From 79ee4b4da096dd6d6a8ae2b8a3b5049e4c54e836 Mon Sep 17 00:00:00 2001 From: ThomasAmpen Date: Sat, 11 Jul 2015 21:27:57 +0200 Subject: [PATCH] HdTorrents --- src/Jackett/Indexers/HDTorrents.cs | 144 ++++++++++++++++++++ src/Jackett/Jackett.csproj | 1 + src/Jackett/WebContent/logos/hdtorrents.png | Bin 0 -> 9574 bytes 3 files changed, 145 insertions(+) create mode 100644 src/Jackett/Indexers/HDTorrents.cs create mode 100644 src/Jackett/WebContent/logos/hdtorrents.png diff --git a/src/Jackett/Indexers/HDTorrents.cs b/src/Jackett/Indexers/HDTorrents.cs new file mode 100644 index 000000000..a831bd75a --- /dev/null +++ b/src/Jackett/Indexers/HDTorrents.cs @@ -0,0 +1,144 @@ +using CsQuery; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; + +namespace Jackett.Indexers +{ + public class HDTorrents : IndexerInterface + { + public event Action OnSaveConfigurationRequested; + + public event Action OnResultParsingError; + + const string DefaultUrl = "https://hd-torrents.org"; + string BaseUrl; + static string ChromeUserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36"; + private string Search_url = "https://hd-torrents.org/torrents.php?search={0}&active=1&options=0&category%5B%5D=59&category%5B%5D=60&category%5B%5D=30&category%5B%5D=38&page={0}"; + private static string LoginUrl = DefaultUrl + "/login.php"; + private static string LoginPostUrl = DefaultUrl + "/index.php"; + CookieContainer cookies; + HttpClientHandler handler; + HttpClient client; + + public HDTorrents() + { + IsConfigured = false; + cookies = new CookieContainer(); + handler = new HttpClientHandler + { + CookieContainer = cookies, + AllowAutoRedirect = true, + UseCookies = true, + }; + client = new HttpClient(handler); + } + + public string DisplayName + { + get { return "HD-Torrents"; } + } + + public string DisplayDescription + { + get { return "HD-Torrents is a private torrent website with HD torrents and strict rules on their content."; } + } + + public Uri SiteLink + { + get { return new Uri(DefaultUrl); } + } + + public bool IsConfigured + { + get; + private set; + } + + public async Task GetConfigurationForSetup() + { + var request = CreateHttpRequest(new Uri(LoginUrl)); + + var response = await client.SendAsync(request); + await response.Content.ReadAsStreamAsync(); + var config = new ConfigurationDataBasicLogin(); + return config; + } + + HttpRequestMessage CreateHttpRequest(Uri uri) + { + var message = new HttpRequestMessage(); + message.Method = HttpMethod.Get; + message.RequestUri = uri; + message.Headers.UserAgent.ParseAdd(ChromeUserAgent); + return message; + } + + public async Task ApplyConfiguration(JToken configJson) + { + var config = new ConfigurationDataBasicLogin(); + config.LoadValuesFromJson(configJson); + + var pairs = new Dictionary { + { "uid", config.Username.Value }, + { "pwd", config.Password.Value } + }; + + var content = new FormUrlEncodedContent(pairs); + var message = CreateHttpRequest(new Uri(LoginPostUrl)); + message.Method = HttpMethod.Post; + message.Content = content; + message.Headers.Referrer = new Uri(LoginPostUrl); + + var response = await client.SendAsync(message); + var responseContent = await response.Content.ReadAsStringAsync(); + + if (!responseContent.Contains("/logout.php")) + { + CQ dom = responseContent; + var messageEl = dom[".error_text"]; + var errorMessage = messageEl.Text().Trim(); + throw new ExceptionWithConfigData(errorMessage, (ConfigurationData)config); + } + else + { + var configSaveData = new JObject(); + configSaveData["cookies"] = cookies.ToJson(SiteLink); + + if (OnSaveConfigurationRequested != null) + OnSaveConfigurationRequested(this, configSaveData); + + IsConfigured = true; + } + } + + public void LoadFromSavedConfiguration(JToken jsonConfig) + { + BaseUrl = (string)jsonConfig["base_url"]; + IsConfigured = true; + } + + async Task PerformQuery(TorznabQuery query, string baseUrl) + { + List releases = new List(); + + + return releases.ToArray(); + } + + public async Task PerformQuery(TorznabQuery query) + { + return await PerformQuery(query, BaseUrl); + } + + public Task Download(Uri link) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/Jackett/Jackett.csproj b/src/Jackett/Jackett.csproj index 351f9cd33..b70d9a276 100644 --- a/src/Jackett/Jackett.csproj +++ b/src/Jackett/Jackett.csproj @@ -97,6 +97,7 @@ + diff --git a/src/Jackett/WebContent/logos/hdtorrents.png b/src/Jackett/WebContent/logos/hdtorrents.png new file mode 100644 index 0000000000000000000000000000000000000000..31254c372bc24c4691e84fe4b47fc0c24f0bedcf GIT binary patch literal 9574 zcmWkzWguOB7{6k=ZA?y1x9RTgp6;&cj%j8(ug+;+On2AxbTbUoHue5}xbBDRob&vj z_{DRgRFtIAQ3z2W5D2=gjD#BaE(0F{Bn0sHqWyded?7o_=zfAgF#2CUFewZeL=Xsy zvW>X7ii)+9o6{$2CucHQad9$dS0_swdkYA}YZxpH>y3@l9KR5!+DW#U%mvzzENdFi$?j0xJzE}CA2Uydh~wF zx6p2({dRxisc}*0pz;#hFooESgqAA9q52^Rtz3*0doy&Xe{gG;StJ;R${B)%)L>5j z>5&o!au*;Vz(CQB*a?C0nngu|bSq|cvl2%>WgxZ9knTw=)OrXK8iZ9fGK>xa?+Y;=rlj=!iBUZ{$@QfP!-(mq3*ni<)O6=*Z>qvs1OnM|3z&XlWN9D_;ztN_ zcq*Vig|{|D&2ztvv8=}wX@uk*E^A*pzvM8!A2oE7aAQE}O^tGZyS3PeTyAgDSYgG#Qgby-oYS9{G znldC8g08T<5&BZC3H-wl_K=70c4@Zc;CfZTIkZOcmNIU_&r$`bKg`|OGUM^`vVOS! zM<^J}m4EP~!WwfqUPye1wfomwM2>!YR_4Jzu{s_`3rJpioWW-dQ*vrV=$Z(%kdub?=%H;oh--`XW|E(!I zTZE1bBjo~4JT42CZ=`rXHx*8lI6FUFdG#F2^p>F8Rer6sW0)OVOSBHm%yItsKD~)*j~`f<-#JsAgfN+FDt@ z2KI+|J+Z3%Cbb&Xh%#JG_e|c2P&`@r;;Mp_Swd@k>sy(8y&~K__(T8ux``z}5Bj$B zN0PP}!EfdHyy6^k9NG#xt~w&{pUI2BshEcETZ zrKY9oRLE4QR!ARra8;j_LQ6U%+jQ@PF+_*tX!L2Mt>PzNK@ZfI)YnQ;O7Rp0`L3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