Compare commits

...

10 Commits

Author SHA1 Message Date
Matthew Little
0b65c92282 Update README.md 2015-04-19 16:05:09 -06:00
zone117x
ac003e7a78 More robust testing/verification for indexers 2015-04-19 16:01:42 -06:00
zone117x
c351cebdfc Completed Bit-HDTV 2015-04-19 15:56:20 -06:00
zone117x
d3484f11ca Fixed ThePirateBay 2015-04-19 14:21:22 -06:00
zone117x
67fbc95ea4 Merge branch 'master' of https://github.com/zone117x/Jackett.git 2015-04-19 01:15:08 -06:00
zone117x
b353022945 Auto escalate privileges 2015-04-19 01:15:02 -06:00
zone117x
58ea700d37 Logging and UI improvements 2015-04-19 01:04:08 -06:00
Matthew Little
db3285551b Update README.md 2015-04-18 23:51:52 -06:00
zone117x
010135da85 Strip parenthesis from show titles - fix for morethantv 2015-04-18 23:31:57 -06:00
zone117x
b68e4c0553 Fixed settings folder bug 2015-04-18 20:05:38 -06:00
24 changed files with 13175 additions and 106 deletions

View File

@@ -7,11 +7,12 @@ This software creates a [Torznab](https://github.com/Sonarr/Sonarr/wiki/Implemen
Currently [Sonarr](https://sonarr.tv/) is the only software that uses Torznab. [Couchpotato](https://couchpota.to/) will hopefully get Torznab support in the future.
### Download
Software is still in development, check back in a few days.
Download in the [Releases page](https://github.com/zone117x/Jackett/releases)
### Supported Trackers
* [BitMeTV](http://www.bitmetv.org/)
* [MoreThan.tv](https://morethan.tv/)
* [BIT-HDTV](https://www.bit-hdtv.com)
* [Freshon](https://freshon.tv/)
* [IPTorrents](https://iptorrents.com/)
* [The Pirate Bay](https://thepiratebay.se/)
@@ -26,4 +27,4 @@ I can be contact on IRC at [irc.freenode.net#sonarr](http://webchat.freenode.net
### Screenshots
![screenshot](http://i.imgur.com/8e2QylW.png "screenshot")
![screenshot](http://i.imgur.com/ca3lKif.png "screenshot")

View File

@@ -20,9 +20,6 @@ namespace Jackett
// Called when web API wants to apply setup configuration via web API, usually this is where login and storing cookie happens
Task ApplyConfiguration(JToken configJson);
// Called to check if configuration (cookie) is correct and indexer connection works
Task VerifyConnection();
// Invoked when the indexer configuration has been applied and verified so the cookie needs to be saved
event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;

View File

@@ -85,5 +85,13 @@ namespace Jackett
LoadMissingIndexers();
}
public async Task TestIndexer(IndexerInterface indexer)
{
var browseQuery = new TorznabQuery();
var results = await indexer.PerformQuery(browseQuery);
if (results.Length == 0)
throw new Exception("Found no results while trying to browse this tracker");
}
}
}

View File

@@ -0,0 +1,163 @@
using CsQuery;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace Jackett.Indexers
{
public class BitHdtv : IndexerInterface
{
public string DisplayName
{
get { return "BIT-HDTV"; }
}
public string DisplayDescription
{
get { return "Home of high definition invites"; }
}
public Uri SiteLink
{
get { return new Uri(BaseUrl); }
}
static string BaseUrl = "https://www.bit-hdtv.com";
static string LoginUrl = BaseUrl + "/takelogin.php";
static string SearchUrl = BaseUrl + "/torrents.php?cat=0&search=";
static string DownloadUrl = BaseUrl + "/download.php?/{0}/dl.torrent";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
public BitHdtv()
{
IsConfigured = false;
cookies = new CookieContainer();
handler = new HttpClientHandler
{
CookieContainer = cookies,
AllowAutoRedirect = true,
UseCookies = true,
};
client = new HttpClient(handler);
}
public Task<ConfigurationData> GetConfigurationForSetup()
{
var config = new ConfigurationDataBasicLogin();
return Task.FromResult<ConfigurationData>(config);
}
public async Task ApplyConfiguration(JToken configJson)
{
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 response = await client.PostAsync(LoginUrl, content);
var responseContent = await response.Content.ReadAsStringAsync();
if (!responseContent.Contains("logout.php"))
{
CQ dom = responseContent;
var messageEl = dom["table.detail td.text"].Last();
messageEl.Children("a").Remove();
messageEl.Children("style").Remove();
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 event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
public bool IsConfigured { get; private set; }
public void LoadFromSavedConfiguration(JToken jsonConfig)
{
cookies.FillFromJson(new Uri(BaseUrl), (JArray)jsonConfig["cookies"]);
IsConfigured = true;
}
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
{
List<ReleaseInfo> releases = new List<ReleaseInfo>();
foreach (var title in query.ShowTitles ?? new string[] { string.Empty })
{
var searchString = title + " " + query.GetEpisodeSearchString();
var episodeSearchUrl = SearchUrl + HttpUtility.UrlEncode(searchString);
var results = await client.GetStringAsync(episodeSearchUrl);
CQ dom = results;
dom["#needseed"].Remove();
var rows = dom["table[width='750'] > tbody"].Children();
foreach (var row in rows.Skip(1))
{
var release = new ReleaseInfo();
var qRow = row.Cq();
var qLink = qRow.Children().ElementAt(2).Cq().Children("a").First();
release.MinimumRatio = 1;
release.MinimumSeedTime = 172800;
release.Title = qLink.Attr("title");
release.Description = release.Title;
release.Guid = new Uri(BaseUrl + qLink.Attr("href"));
release.Comments = release.Guid;
release.Link = new Uri(string.Format(DownloadUrl, qLink.Attr("href").Split('=')[1]));
var dateString = qRow.Children().ElementAt(5).Cq().Text().Trim();
var pubDate = DateTime.ParseExact(dateString, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
release.PublishDate = pubDate;
var sizeCol = qRow.Children().ElementAt(6);
var sizeVal = sizeCol.ChildNodes[0].NodeValue;
var sizeUnit = sizeCol.ChildNodes[2].NodeValue;
release.Size = ReleaseInfo.GetBytes(sizeUnit, float.Parse(sizeVal));
release.Seeders = int.Parse(qRow.Children().ElementAt(8).Cq().Text().Trim());
release.Peers = int.Parse(qRow.Children().ElementAt(9).Cq().Text().Trim()) + release.Seeders;
releases.Add(release);
}
}
return releases.ToArray();
}
public Task<byte[]> Download(Uri link)
{
return client.GetByteArrayAsync(link);
}
}
}

View File

@@ -118,13 +118,6 @@ namespace Jackett
}
}
public async Task VerifyConnection()
{
var result = await client.GetStringAsync(new Uri(SearchUrl));
if (result.Contains("<h1>Not logged in!</h1>"))
throw new Exception("Detected as not logged in");
}
public void LoadFromSavedConfiguration(JToken jsonConfig)
{
cookies.FillFromJson(new Uri(BaseUrl), (JArray)jsonConfig["cookies"]);

View File

@@ -51,10 +51,13 @@ namespace Jackett
client = new HttpClient(handler);
}
public Task<ConfigurationData> GetConfigurationForSetup()
public async Task<ConfigurationData> GetConfigurationForSetup()
{
var request = CreateHttpRequest(new Uri(LoginUrl));
var response = await client.SendAsync(request);
await response.Content.ReadAsStreamAsync();
var config = new ConfigurationDataBasicLogin();
return Task.FromResult<ConfigurationData>(config);
return config;
}
public async Task ApplyConfiguration(JToken configJson)
@@ -72,6 +75,7 @@ namespace Jackett
var message = CreateHttpRequest(new Uri(LoginPostUrl));
message.Method = HttpMethod.Post;
message.Content = content;
message.Headers.Referrer = new Uri(LoginUrl);
var response = await client.SendAsync(message);
var responseContent = await response.Content.ReadAsStringAsync();
@@ -98,16 +102,6 @@ namespace Jackett
}
}
public async Task VerifyConnection()
{
var message = CreateHttpRequest(new Uri(SearchUrl));
var response = await client.SendAsync(message);
var result = await response.Content.ReadAsStringAsync();
if (!result.Contains("/logout.php"))
throw new Exception("Detected as not logged in");
}
public void LoadFromSavedConfiguration(JToken jsonConfig)
{
cookies.FillFromJson(new Uri(BaseUrl), (JArray)jsonConfig["cookies"]);

View File

@@ -111,19 +111,6 @@ namespace Jackett.Indexers
return message;
}
public Task VerifyConnection()
{
return Task.Run(async () =>
{
var message = CreateHttpRequest(new Uri(BaseUrl));
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"]);

View File

@@ -0,0 +1,184 @@
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;
using System.Web;
namespace Jackett.Indexers
{
public class MoreThanTV : IndexerInterface
{
public string DisplayName
{
get { return "MoreThanTV"; }
}
public string DisplayDescription
{
get { return "ROMANIAN Private Torrent Tracker for TV / MOVIES, and the internal tracker for the release group DRACULA"; }
}
public Uri SiteLink
{
get { return new Uri(BaseUrl); }
}
public event Action<IndexerInterface, JToken> OnSaveConfigurationRequested;
public bool IsConfigured { get; private set; }
static string BaseUrl = "http://www.morethan.tv";
static string LoginUrl = BaseUrl + "/login.php";
static string SearchUrl = BaseUrl + "/ajax.php?action=browse&searchstr=";
static string DownloadUrl = BaseUrl + "/torrents.php?action=download&id=";
static string GuidUrl = BaseUrl + "/torrents.php?torrentid=";
CookieContainer cookies;
HttpClientHandler handler;
HttpClient client;
public MoreThanTV()
{
IsConfigured = false;
cookies = new CookieContainer();
handler = new HttpClientHandler
{
CookieContainer = cookies,
AllowAutoRedirect = true,
UseCookies = true,
};
client = new HttpClient(handler);
}
public Task<ConfigurationData> GetConfigurationForSetup()
{
var config = new ConfigurationDataBasicLogin();
return Task.FromResult<ConfigurationData>(config);
}
public async Task ApplyConfiguration(Newtonsoft.Json.Linq.JToken configJson)
{
var config = new ConfigurationDataBasicLogin();
config.LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string>
{
{ "username", config.Username.Value},
{ "password", config.Password.Value},
{ "login", "Log in" },
{ "keeplogged", "1" }
};
var content = new FormUrlEncodedContent(pairs);
var response = await client.PostAsync(LoginUrl, content);
var responseContent = await response.Content.ReadAsStringAsync();
if (!responseContent.Contains("logout.php?"))
{
CQ dom = responseContent;
dom["#loginform > table"].Remove();
var errorMessage = dom["#loginform"].Text().Trim().Replace("\n\t", " ");
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 void LoadFromSavedConfiguration(Newtonsoft.Json.Linq.JToken jsonConfig)
{
cookies.FillFromJson(new Uri(BaseUrl), (JArray)jsonConfig["cookies"]);
IsConfigured = true;
}
void FillReleaseInfoFromJson(ReleaseInfo release, JObject r)
{
var id = r["torrentId"];
release.Size = (long)r["size"];
release.Seeders = (int)r["seeders"];
release.Peers = (int)r["leechers"] + release.Seeders;
release.Guid = new Uri(GuidUrl + id);
release.Comments = release.Guid;
release.Link = new Uri(DownloadUrl + id);
}
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
{
List<ReleaseInfo> releases = new List<ReleaseInfo>();
foreach (var title in query.ShowTitles ?? new string[] { string.Empty })
{
var searchString = title + " " + query.GetEpisodeSearchString();
var episodeSearchUrl = SearchUrl + HttpUtility.UrlEncode(searchString);
var results = await client.GetStringAsync(episodeSearchUrl);
var json = JObject.Parse(results);
foreach (JObject r in json["response"]["results"])
{
var pubDate = UnixTimestampToDateTime(double.Parse((string)r["groupTime"]));
var groupName = (string)r["groupName"];
if (r["torrents"] is JArray)
{
foreach (JObject t in r["torrents"])
{
var release = new ReleaseInfo();
release.PublishDate = pubDate;
release.Title = groupName;
release.Description = groupName;
FillReleaseInfoFromJson(release, t);
releases.Add(release);
}
}
else
{
var release = new ReleaseInfo();
release.PublishDate = pubDate;
release.Title = groupName;
release.Description = groupName;
FillReleaseInfoFromJson(release, r);
releases.Add(release);
}
}
}
return releases.ToArray();
}
static DateTime UnixTimestampToDateTime(double unixTime)
{
DateTime unixStart = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
long unixTimeStampInTicks = (long)(unixTime * TimeSpan.TicksPerSecond);
return new DateTime(unixStart.Ticks + unixTimeStampInTicks);
}
public Task<byte[]> Download(Uri link)
{
return client.GetByteArrayAsync(link);
}
}
}

View File

@@ -95,12 +95,6 @@ namespace Jackett.Indexers
IsConfigured = true;
}
public async Task VerifyConnection()
{
await TestBrowse(BaseUrl);
}
async Task TestBrowse(string url)
{
var result = await client.GetStringAsync(new Uri(url) + BrowserUrl);

View File

@@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E636D5F8-68B4-4903-B4ED-CCFD9C9E899F}</ProjectGuid>
<OutputType>Exe</OutputType>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Jackett</RootNamespace>
<AssemblyName>Jackett</AssemblyName>
@@ -47,6 +47,12 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>jacket_large.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Jackett.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="CsQuery">
<HintPath>..\packages\CsQuery.1.3.4\lib\net40\CsQuery.dll</HintPath>
@@ -55,11 +61,16 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>..\packages\NLog.3.2.0.0\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -76,11 +87,18 @@
<Compile Include="ExceptionWithConfigData.cs" />
<Compile Include="IndexerInterface.cs" />
<Compile Include="IndexerManager.cs" />
<Compile Include="Indexers\BitHdtv.cs" />
<Compile Include="Indexers\BitMeTV.cs" />
<Compile Include="Indexers\Freshon.cs" />
<Compile Include="Indexers\IPTorrents.cs" />
<Compile Include="Indexers\MoreThanTV.cs" />
<Compile Include="Indexers\ThePirateBay.cs" />
<Compile Include="Main.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Main.Designer.cs">
<DependentUpon>Main.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
@@ -107,12 +125,16 @@
<None Include="Resources\test.xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Main.resx">
<DependentUpon>Main.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Content Include="jacket_large.ico" />
<Content Include="WebContent\animate.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@@ -128,9 +150,18 @@
<Content Include="WebContent\crissXcross.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="WebContent\favicon.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="WebContent\handlebars-v3.0.1.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="WebContent\jacket_medium.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="WebContent\logos\bithdtv.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="WebContent\logos\bitmetv.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

100
src/Jackett/Main.Designer.cs generated Normal file
View File

@@ -0,0 +1,100 @@
namespace Jackett
{
partial class Main
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItemAutoStart = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemWebUI = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemShutdown = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// notifyIcon1
//
this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
this.notifyIcon1.Text = "Jackett";
this.notifyIcon1.Visible = true;
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItemAutoStart,
this.toolStripMenuItemWebUI,
this.toolStripMenuItemShutdown});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(174, 92);
//
// toolStripMenuItemAutoStart
//
this.toolStripMenuItemAutoStart.CheckOnClick = true;
this.toolStripMenuItemAutoStart.Name = "toolStripMenuItemAutoStart";
this.toolStripMenuItemAutoStart.Size = new System.Drawing.Size(173, 22);
this.toolStripMenuItemAutoStart.Text = "Auto-start on boot";
//
// toolStripMenuItemWebUI
//
this.toolStripMenuItemWebUI.Name = "toolStripMenuItemWebUI";
this.toolStripMenuItemWebUI.Size = new System.Drawing.Size(173, 22);
this.toolStripMenuItemWebUI.Text = "Open Web UI";
//
// toolStripMenuItemShutdown
//
this.toolStripMenuItemShutdown.Name = "toolStripMenuItemShutdown";
this.toolStripMenuItemShutdown.Size = new System.Drawing.Size(173, 22);
this.toolStripMenuItemShutdown.Text = "Shutdown";
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(326, 176);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Main";
this.ShowInTaskbar = false;
this.Text = "Jackett";
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAutoStart;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemWebUI;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemShutdown;
}
}

70
src/Jackett/Main.cs Normal file
View File

@@ -0,0 +1,70 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Jackett
{
public partial class Main : Form
{
public Main()
{
Hide();
InitializeComponent();
toolStripMenuItemAutoStart.Checked = AutoStart;
toolStripMenuItemAutoStart.CheckedChanged += toolStripMenuItemAutoStart_CheckedChanged;
toolStripMenuItemShutdown.Click += toolStripMenuItemShutdown_Click;
if (Program.IsFirstRun)
AutoStart = true;
}
void toolStripMenuItemShutdown_Click(object sender, EventArgs e)
{
Application.Exit();
}
void toolStripMenuItemAutoStart_CheckedChanged(object sender, EventArgs e)
{
AutoStart = toolStripMenuItemAutoStart.Checked;
}
string ProgramTitle
{
get
{
return Assembly.GetExecutingAssembly().GetName().Name;
}
}
bool AutoStart
{
get
{
RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (rkApp.GetValue(ProgramTitle) == null)
return false;
else
return true;
}
set
{
RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (value && !AutoStart)
rkApp.SetValue(ProgramTitle, Application.ExecutablePath.ToString());
else if (!value && AutoStart)
rkApp.DeleteValue(ProgramTitle, false);
}
}
}
}

12471
src/Jackett/Main.resx Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,16 @@
using System;
using NLog;
using NLog.Config;
using NLog.Targets;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Jackett
{
@@ -13,59 +18,66 @@ namespace Jackett
{
public static string AppConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Jackett");
public static ManualResetEvent ExitEvent = new ManualResetEvent(false);
public static Server ServerInstance { get; private set; }
public static bool IsFirstRun { get; private set; }
public static Logger LoggerInstance { get; private set; }
static void Main(string[] args)
{
//var descRegex = new Regex("Uploaded (?<month>.*?)-(?<day>.*?) (?<year>.*?), Size (?<size>.*?) (?<unit>.*?), ULed");
var descRegex = new Regex("Uploaded (?<month>.*?)-(?<day>.*?) (?<year>.*?), Size (?<size>.*?) (?<unit>.*?), ULed by");
var m = descRegex.Match(("Uploaded 06-03 2013, Size 329.84 MiB, ULed by"));
List<string> matches = new List<string>();
var date = m.Groups["month"].Value;
for (var i = 0; i < m.Groups.Count; i++)
try
{
var group = m.Groups[i];
matches.Add(group.Value); ;
if (!Directory.Exists(AppConfigDirectory))
{
IsFirstRun = true;
Directory.CreateDirectory(AppConfigDirectory);
}
}
//Uploaded 08-02&nbsp;2007, Size 47.15&nbsp;MiB, ULed
//Uploaded (<date>.*?)&nbsp;2007, Size 47.15&nbsp;MiB, ULed
var resultPage = new ResultPage(new ChannelInfo
catch (Exception ex)
{
Title = "HDAccess",
Description = "Jackett for HDAccess",
Link = new Uri("http://hdaccess.net"),
ImageUrl = new Uri("https://hdaccess.net/logo_small.png"),
ImageTitle = "HDAccess",
ImageLink = new Uri("https://hdaccess.net"),
ImageDescription = "Jackett for HDAccess"
});
MessageBox.Show("Could not create settings directory.");
Application.Exit();
return;
}
resultPage.Releases.Add(new ReleaseInfo
{
Title = "Better Call Saul S01E05 Alpine Shepherd 1080p NF WEBRip DD5.1 x264",
Guid = new Uri("https://hdaccess.net/details.php?id=11515"),
Link = new Uri("https://hdaccess.net/download.php?torrent=11515&amp;passkey=123456"),
Comments = new Uri("https://hdaccess.net/details.php?id=11515&amp;hit=1#comments"),
PublishDate = DateTime.Now,
Category = "HDTV 1080p",
Size = 2538463390,
Description = "Better.Call.Saul.S01E05.Alpine.Shepherd.1080p.NF.WEBRip.DD5.1.x264.torrent",
Seeders = 7,
Peers = 6,
InfoHash = "63e07ff523710ca268567dad344ce1e0e6b7e8a3",
MinimumRatio = 1.0,
MinimumSeedTime = 172800
});
var logConfig = new LoggingConfiguration();
var f = resultPage.ToXml(new Uri("http://localhost:9117"));
var logFile = new FileTarget();
logConfig.AddTarget("file", logFile);
logFile.FileName = Path.Combine(AppConfigDirectory, "log.txt");
logFile.Layout = "${longdate} ${level} ${message}";
var logFileRule = new LoggingRule("*", LogLevel.Debug, logFile);
var logAlert = new MessageBoxTarget();
logConfig.AddTarget("alert", logAlert);
logAlert.Layout = "${message}";
logAlert.Caption = "Alert";
var logAlertRule = new LoggingRule("*", LogLevel.Error, logAlert);
logConfig.LoggingRules.Add(logFileRule);
logConfig.LoggingRules.Add(logAlertRule);
LogManager.Configuration = logConfig;
LoggerInstance = LogManager.GetCurrentClassLogger();
Task.Run(() =>
{
var server = new Server();
server.Start();
ServerInstance = new Server();
ServerInstance.Start();
});
ExitEvent.WaitOne();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
}
static public void RestartAsAdmin()
{
var startInfo = new ProcessStartInfo(Application.ExecutablePath.ToString()) { Verb = "runas" };
Process.Start(startInfo);
Environment.Exit(0);
}
}
}

View File

@@ -76,7 +76,7 @@ namespace Jackett
"enclosure",
new XAttribute("url", r.Link ?? r.MagnetUrl),
new XAttribute("length", r.Size),
new XAttribute("type", r.Link == null ? "application/x-bittorrent;x-scheme-handler/magnet" : "application/x-bittorrent")
new XAttribute("type", "application/x-bittorrent")
),
getTorznabElement("magneturl", r.MagnetUrl),
getTorznabElement("rageid", r.RageID),

View File

@@ -2,17 +2,21 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Windows.Forms;
namespace Jackett
{
public class Server
{
int Port = 9117;
HttpListener listener;
IndexerManager indexerManager;
WebApi webApi;
@@ -44,7 +48,37 @@ namespace Jackett
public async void Start()
{
listener.Start();
Program.LoggerInstance.Info("Starting HTTP server...");
try
{
listener.Start();
Process.Start("http://127.0.0.1:" + Port);
}
catch (HttpListenerException ex)
{
var dialogResult = MessageBox.Show(
"App must be ran as Admin for permission to use port " + Port + Environment.NewLine + "Restart app with admin privileges?",
"Failed to open port",
MessageBoxButtons.YesNo
);
if (dialogResult == DialogResult.No)
{
Program.LoggerInstance.FatalException("App must be ran as Admin for permission to use port " + Port, ex);
Application.Exit();
return;
}
else
{
Program.RestartAsAdmin();
}
}
catch (Exception ex)
{
Program.LoggerInstance.ErrorException("Error: " + ex.Message, ex);
return;
}
Program.LoggerInstance.Info("Server started on port " + Port);
while (true)
{
var context = await listener.GetContextAsync();
@@ -60,6 +94,7 @@ namespace Jackett
async void ProcessHttpRequest(HttpListenerContext context)
{
Program.LoggerInstance.Trace("Received request: " + context.Request.Url.ToString());
Exception exception = null;
try
{
@@ -138,6 +173,8 @@ namespace Jackett
// add Jackett proxy to download links...
foreach (var release in releases)
{
if (release.Link == null || release.Link.Scheme == "magnet")
continue;
var originalLink = release.Link;
var encodedLink = HttpServerUtility.UrlTokenEncode(Encoding.UTF8.GetBytes(originalLink.ToString())) + "/download.torrent";
var proxyLink = string.Format("{0}api/{1}/download/{2}", severUrl, indexerId, encodedLink);

View File

@@ -1,5 +1,6 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -45,7 +46,7 @@ namespace Jackett
HttpClientHandler handler;
HttpClient client;
Dictionary<int, string[]> IdNameMappings;
ConcurrentDictionary<int, string[]> IdNameMappings;
public SonarrApi()
{
@@ -60,7 +61,7 @@ namespace Jackett
};
client = new HttpClient(handler);
IdNameMappings = new Dictionary<int, string[]>();
IdNameMappings = new ConcurrentDictionary<int, string[]>();
}
async Task ReloadNameMappings(string host, int port, string apiKey)
@@ -74,15 +75,20 @@ namespace Jackett
foreach (var item in json)
{
var titles = new List<string>();
titles.Add((string)item["title"]);
titles.Add(SanitizeTitle((string)item["title"]));
foreach (var t in item["alternateTitles"])
{
titles.Add((string)t["title"]);
titles.Add(SanitizeTitle((string)t["title"]));
}
IdNameMappings.Add((int)item["tvRageId"], titles.ToArray());
IdNameMappings.TryAdd((int)item["tvRageId"], titles.ToArray());
}
}
string SanitizeTitle(string title)
{
return title.Replace("(", "").Replace(")", "");
}
void LoadSettings()
{
try

View File

@@ -228,7 +228,7 @@ namespace Jackett
var indexer = indexerManager.GetIndexer(indexerString);
jsonReply["name"] = indexer.DisplayName;
await indexer.ApplyConfiguration(postData["config"]);
await indexer.VerifyConnection();
await indexerManager.TestIndexer(indexer);
jsonReply["result"] = "success";
}
catch (Exception ex)
@@ -281,7 +281,7 @@ namespace Jackett
string indexerString = (string)postData["indexer"];
var indexer = indexerManager.GetIndexer(indexerString);
jsonReply["name"] = indexer.DisplayName;
await indexer.VerifyConnection();
await indexerManager.TestIndexer(indexer);
jsonReply["result"] = "success";
}
catch (Exception ex)

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

View File

@@ -4,6 +4,8 @@
<head>
<meta charset="utf-8" />
<link rel='shortcut icon' type='image/x-icon' href='/favicon.ico' />
<script src="jquery-2.1.3.min.js"></script>
<script src="handlebars-v3.0.1.js"></script>
<script src="bootstrap/bootstrap.min.js"></script>
@@ -181,11 +183,22 @@
#sonarr-warning {
display: none;
}
#logo {
max-width: 50px;
}
#header-title {
font-size: 34px;
vertical-align: middle;
padding-left: 15px;
}
</style>
</head>
<body>
<div id="page">
<h3><span>need a logo..</span></h3>
<img id="logo" src="jacket_medium.png" /><span id="header-title">Jackett</span>
<hr />
@@ -233,6 +246,10 @@
<div class="modal-body">
<div id="unconfigured-indexers">
</div>
<hr />
<p>
To add a Jackett indexer in Sonarr go to <b>Settings > Indexers > Add > Torznab > Custom</b>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
@@ -509,6 +526,17 @@
$("#select-indexer-modal").modal("hide");
}
function populateConfigItems(configForm, config) {
var $formItemContainer = configForm.find(".config-setup-form");
$formItemContainer.empty();
var setupItemTemplate = Handlebars.compile($("#templates > .setup-item")[0].outerHTML);
for (var i = 0; i < config.length; i++) {
var item = config[i];
var setupValueTemplate = Handlebars.compile($("#templates > .setup-item-" + item.type)[0].outerHTML);
item.value_element = setupValueTemplate(item);
$formItemContainer.append(setupItemTemplate(item));
}
}
function newConfigModal(title, config) {
//config-setup-modal
@@ -517,15 +545,7 @@
$("#modals").append(configForm);
var $formItemContainer = configForm.find(".config-setup-form");
var setupItemTemplate = Handlebars.compile($("#templates > .setup-item")[0].outerHTML);
for (var i = 0; i < config.length; i++) {
var item = config[i];
var setupValueTemplate = Handlebars.compile($("#templates > .setup-item-" + item.type)[0].outerHTML);
item.value_element = setupValueTemplate(item);
$formItemContainer.append(setupItemTemplate(item));
}
populateConfigItems(configForm, config);
return configForm;
//modal.remove();
@@ -565,7 +585,7 @@
var jqxhr = $.post("configure_indexer", JSON.stringify(data), function (data) {
if (data.result == "error") {
if (data.config) {
populateSetupForm(data.indexer, data.name, data.config);
populateConfigItems(configForm, data.config);
}
doNotify("Configuration failed: " + data.error, "danger", "glyphicon glyphicon-alert");
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

View File

@@ -2,4 +2,5 @@
<packages>
<package id="CsQuery" version="1.3.4" targetFramework="net451" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
<package id="NLog" version="3.2.0.0" targetFramework="net451" />
</packages>