mirror of
https://github.com/Jackett/Jackett
synced 2025-03-04 02:38:08 +00:00
Logging and UI improvements
This commit is contained in:
parent
010135da85
commit
58ea700d37
11 changed files with 12759 additions and 27 deletions
|
@ -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();
|
||||
|
|
|
@ -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" />
|
||||
|
@ -81,6 +92,12 @@
|
|||
<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 +124,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>
|
||||
|
@ -131,6 +152,9 @@
|
|||
<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\bitmetv.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
|
100
src/Jackett/Main.Designer.cs
generated
Normal file
100
src/Jackett/Main.Designer.cs
generated
Normal 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
70
src/Jackett/Main.cs
Normal 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
12471
src/Jackett/Main.resx
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,7 @@
|
|||
using System;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NLog.Targets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -6,6 +9,7 @@ using System.Text;
|
|||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Jackett
|
||||
{
|
||||
|
@ -13,27 +17,59 @@ 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)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(AppConfigDirectory))
|
||||
{
|
||||
IsFirstRun = true;
|
||||
Directory.CreateDirectory(AppConfigDirectory);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine("Could not create settings directory");
|
||||
MessageBox.Show("Could not create settings directory.");
|
||||
Application.Exit();
|
||||
return;
|
||||
}
|
||||
|
||||
var logConfig = new LoggingConfiguration();
|
||||
|
||||
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());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,23 +48,25 @@ namespace Jackett
|
|||
|
||||
public async void Start()
|
||||
{
|
||||
Console.WriteLine("Starting HTTP server...");
|
||||
Program.LoggerInstance.Info("Starting HTTP server...");
|
||||
|
||||
try
|
||||
{
|
||||
listener.Start();
|
||||
Process.Start("http://127.0.0.1:" + Port);
|
||||
}
|
||||
catch (HttpListenerException ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine("App must be ran as Admin for permission to use port");
|
||||
Program.LoggerInstance.FatalException("App must be ran as Admin for permission to use port " + Port, ex);
|
||||
Application.Exit();
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error " + ex.ToString());
|
||||
Program.LoggerInstance.ErrorException("Error: " + ex.Message, ex);
|
||||
return;
|
||||
}
|
||||
Console.WriteLine("Server started on port 9117");
|
||||
Program.LoggerInstance.Info("Server started on port " + Port);
|
||||
while (true)
|
||||
{
|
||||
var context = await listener.GetContextAsync();
|
||||
|
@ -76,7 +82,7 @@ namespace Jackett
|
|||
|
||||
async void ProcessHttpRequest(HttpListenerContext context)
|
||||
{
|
||||
Console.WriteLine("Received request: " + context.Request.Url.ToString());
|
||||
Program.LoggerInstance.Trace("Received request: " + context.Request.Url.ToString());
|
||||
Exception exception = null;
|
||||
try
|
||||
{
|
||||
|
@ -155,6 +161,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);
|
||||
|
|
|
@ -181,11 +181,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 +244,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 +524,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 +543,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 +583,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");
|
||||
}
|
||||
|
|
BIN
src/Jackett/WebContent/jacket_medium.png
Normal file
BIN
src/Jackett/WebContent/jacket_medium.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
BIN
src/Jackett/jacket_large.ico
Normal file
BIN
src/Jackett/jacket_large.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 361 KiB |
|
@ -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>
|
Loading…
Add table
Reference in a new issue