Added IPTorrents

This commit is contained in:
zone117x 2015-04-15 19:16:16 -06:00
parent 116cbed625
commit 08c63226d1
8 changed files with 299 additions and 31 deletions

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jackett
{
public class ConfigurationDataBasicLogin : ConfigurationData
{
public StringItem Username { get; private set; }
public StringItem Password { get; private set; }
public ConfigurationDataBasicLogin()
{
Username = new StringItem { Name = "Username", ItemType = ItemType.InputString };
Password = new StringItem { Name = "Password", ItemType = ItemType.InputString };
}
public override Item[] GetItems()
{
return new Item[] { Username, Password };
}
}
}

View File

@ -14,22 +14,6 @@ namespace Jackett
{
public class Freshon : IndexerInterface
{
class FreshonConfig : ConfigurationData
{
public StringItem Username { get; private set; }
public StringItem Password { get; private set; }
public FreshonConfig()
{
Username = new StringItem { Name = "Username", ItemType = ItemType.InputString };
Password = new StringItem { Name = "Password", ItemType = ItemType.InputString };
}
public override Item[] GetItems()
{
return new Item[] { Username, Password };
}
}
static string BaseUrl = "https://freshon.tv";
static string LoginUrl = BaseUrl + "/login.php";
@ -67,10 +51,9 @@ namespace Jackett
public Task<ConfigurationData> GetConfigurationForSetup()
{
return Task.Run(async () =>
return Task.Run(() =>
{
//var loginPage = await client.GetAsync(LoginUrl);
var config = new FreshonConfig();
var config = new ConfigurationDataBasicLogin();
return (ConfigurationData)config;
});
}
@ -79,7 +62,7 @@ namespace Jackett
{
return Task.Run(async () =>
{
var config = new FreshonConfig();
var config = new ConfigurationDataBasicLogin();
config.LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string>

View File

@ -0,0 +1,126 @@
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 IPTorrents : IndexerInterface
{
public event Action<IndexerInterface, Newtonsoft.Json.Linq.JToken> OnSaveConfigurationRequested;
public string DisplayName { get { return "IPTorrents"; } }
public string DisplayDescription { get { return "Always a step ahead"; } }
public Uri SiteLink { get { return new Uri("https://iptorrents.com"); } }
public bool IsConfigured { get; private set; }
static string BaseUrl = "https://iptorrents.com";
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";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
public IPTorrents()
{
IsConfigured = false;
cookies = new CookieContainer();
handler = new HttpClientHandler
{
CookieContainer = cookies,
AllowAutoRedirect = true,
UseCookies = true,
};
client = new HttpClient(handler);
}
public Task<ConfigurationData> GetConfigurationForSetup()
{
return Task.Run(async () =>
{
await client.GetAsync(new Uri(BaseUrl));
var config = new ConfigurationDataBasicLogin();
return (ConfigurationData)config;
});
}
public Task ApplyConfiguration(Newtonsoft.Json.Linq.JToken configJson)
{
return Task.Run(async () =>
{
var config = new ConfigurationDataBasicLogin();
config.LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string>
{
{ "username", config.Username.Value},
{ "password", config.Password.Value}
};
var content = new FormUrlEncodedContent(pairs);
var message = new HttpRequestMessage();
message.Method = HttpMethod.Post;
message.Content = content;
message.RequestUri = new Uri(BaseUrl);
message.Headers.Referrer = new Uri(BaseUrl);
message.Headers.UserAgent.ParseAdd(chromeUserAgent);
var response = await client.SendAsync(message);
var responseContent = await response.Content.ReadAsStringAsync();
if (!responseContent.Contains("/my.php"))
{
CQ dom = responseContent;
var messageEl = dom["body > div"].First();
var errorMessage = messageEl.Text().Trim();
throw new ExceptionWithConfigData(errorMessage, (ConfigurationData)config);
}
else
{
var configSaveData = new JObject();
configSaveData["cookies"] = new JArray((
from cookie in cookies.GetCookies(new Uri(BaseUrl)).Cast<Cookie>()
select cookie.Name + ":" + cookie.Value
).ToArray());
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
IsConfigured = true;
}
});
}
public Task VerifyConnection()
{
return Task.Run(async () =>
{
var message = new HttpRequestMessage();
message.Method = HttpMethod.Get;
message.RequestUri = new Uri(BaseUrl);
message.Headers.UserAgent.ParseAdd(chromeUserAgent);
var response = await client.SendAsync(message);
var result = await response.Content.ReadAsStringAsync();
if (!result.Contains("/my.php"))
throw new Exception("Detected as not logged in");
});
}
public void LoadFromSavedConfiguration(Newtonsoft.Json.Linq.JToken jsonConfig)
{
cookies.FillFromJson(new Uri(BaseUrl), (JArray)jsonConfig["cookies"]);
IsConfigured = true;
}
}
}

View File

@ -0,0 +1,117 @@
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 ThePirateBay : IndexerInterface
{
class ThePirateBayConfig : ConfigurationData
{
public StringItem Url { get; private set; }
public ThePirateBayConfig()
{
Url = new StringItem { Name = "Url", ItemType = ItemType.InputString, Value = "https://thepiratebay.se/" };
}
public override Item[] GetItems()
{
return new Item[] { Url };
}
}
public event Action<IndexerInterface, Newtonsoft.Json.Linq.JToken> OnSaveConfigurationRequested;
public string DisplayName { get { return "The Pirate Bay"; } }
public string DisplayDescription { get { return "The worlds largest bittorrent indexer"; } }
public Uri SiteLink { get { return new Uri("https://thepiratebay.se/"); } }
public bool IsConfigured { get; private set; }
static string SearchUrl = "s/?q=test";
static string BrowserUrl = "browse";
string BaseUrl;
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
public ThePirateBay()
{
IsConfigured = false;
cookies = new CookieContainer();
handler = new HttpClientHandler
{
CookieContainer = cookies,
AllowAutoRedirect = true,
UseCookies = true,
};
client = new HttpClient(handler);
}
public Task<ConfigurationData> GetConfigurationForSetup()
{
return Task.Run(() =>
{
var config = new ThePirateBayConfig();
return (ConfigurationData)config;
});
}
public Task ApplyConfiguration(Newtonsoft.Json.Linq.JToken configJson)
{
return Task.Run(async () =>
{
var config = new ThePirateBayConfig();
config.LoadValuesFromJson(configJson);
await TestBrowse(config.Url.Value);
BaseUrl = new Uri(config.Url.Value).ToString();
var configSaveData = new JObject();
configSaveData["base_url"] = BaseUrl;
if (OnSaveConfigurationRequested != null)
OnSaveConfigurationRequested(this, configSaveData);
IsConfigured = true;
});
}
public Task VerifyConnection()
{
return Task.Run(async () =>
{
await TestBrowse(BaseUrl);
});
}
Task TestBrowse(string url)
{
return Task.Run(async () =>
{
var result = await client.GetStringAsync(new Uri(url) + BrowserUrl);
if (!result.Contains("<span>Browse Torrents</span>"))
{
throw new Exception("Could not detect The Pirate Bay content");
}
});
}
public void LoadFromSavedConfiguration(JToken jsonConfig)
{
BaseUrl = (string)jsonConfig["base_url"];
IsConfigured = true;
}
}
}

View File

@ -70,6 +70,7 @@
<Compile Include="ApiKey.cs" />
<Compile Include="ChannelInfo.cs" />
<Compile Include="ConfigurationData.cs" />
<Compile Include="ConfigurationDataBasicLogin.cs" />
<Compile Include="CookieContainerExtensions.cs" />
<Compile Include="DataUrl.cs" />
<Compile Include="ExceptionWithConfigData.cs" />
@ -77,6 +78,8 @@
<Compile Include="IndexerManager.cs" />
<Compile Include="Indexers\BitMeTV.cs" />
<Compile Include="Indexers\Freshon.cs" />
<Compile Include="Indexers\IPTorrents.cs" />
<Compile Include="Indexers\ThePirateBay.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
@ -134,6 +137,12 @@
<Content Include="WebContent\logos\freshon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="WebContent\logos\iptorrents.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="WebContent\logos\thepiratebay.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="WebContent\setup_indexer.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

View File

@ -45,10 +45,11 @@
border-radius: 6px;
box-shadow: 1px 1px 5px 2px #cdcdcd;
padding: 10px;
width: 225px;
width: 220px;
display: inline-block;
margin-right: 30px;
vertical-align: top;
margin-bottom: 30px;
}
.unconfigured-indexer {
@ -56,7 +57,7 @@
}
.indexer {
height: 220px;
height: 265px;
}
#add-indexer {
@ -80,6 +81,15 @@
text-align: center;
}
.indexer-buttons > .btn {
width: 90px;
margin-bottom: 10px;
}
.indexer-buttons > .btn:nth-child(even) {
margin-left: 5px;
}
.indexer-add-content {
color: gray;
text-align: center;
@ -87,7 +97,7 @@
.indexer-add-content > .glyphicon {
font-size: 50px;
margin-top: 35%;
margin-top: 40%;
vertical-align: bottom;
}
@ -97,14 +107,11 @@
margin-left: -5px;
}
.indexer-host {
margin-top: 10px;
}
.indexer-host > input {
font-size: 12px;
padding: 2px;
}
.indexer-host > input {
font-size: 12px;
padding: 2px;
}
.setup-item-inputstring {
max-width: 260px;
@ -180,8 +187,9 @@
<div class="indexer-name"><h3>{{name}}</h3></div>
<div class="indexer-buttons">
<a class="btn btn-info btn-sm" target="_blank" href="{{site_link}}">Visit <span class="glyphicon glyphicon-new-window" aria-hidden="true"></span></a>
<a class="btn btn-warning btn-sm indexer-button-test" href="#" data-id="{{id}}">Test <span class="glyphicon glyphicon-screenshot" aria-hidden="true"></span></a>
<a class="btn btn-danger btn-sm" href="#">Delete <span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
<a class="btn btn-primary btn-sm indexer-button-test" href="#" data-id="{{id}}">Test <span class="glyphicon glyphicon-screenshot" aria-hidden="true"></span></a>
<a class="btn btn-primary btn-sm" href="#">Configure <span class="glyphicon glyphicon-wrench" aria-hidden="true"></span></a>
</div>
<div class="indexer-host">
<b>Torznab Host:</b>

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB