mirror of
https://github.com/Jackett/Jackett
synced 2025-02-25 15:42:48 +00:00
added notice in log when proxying is used
bitsoup multi category searches look for all cats instead of making multiple queries
This commit is contained in:
parent
f4129dc4a0
commit
af0c15be2c
2 changed files with 231 additions and 257 deletions
|
@ -1,225 +1,226 @@
|
||||||
using CommandLine;
|
using CommandLine;
|
||||||
using CommandLine.Text;
|
using CommandLine.Text;
|
||||||
using Jackett;
|
using Jackett;
|
||||||
using Jackett.Console;
|
using Jackett.Console;
|
||||||
using Jackett.Indexers;
|
using Jackett.Indexers;
|
||||||
using Jackett.Utils;
|
using Jackett.Utils;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace JackettConsole
|
namespace JackettConsole
|
||||||
{
|
{
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var options = new ConsoleOptions();
|
var options = new ConsoleOptions();
|
||||||
if (!Parser.Default.ParseArguments(args, options) || options.ShowHelp == true)
|
if (!Parser.Default.ParseArguments(args, options) || options.ShowHelp == true)
|
||||||
{
|
{
|
||||||
if (options.LastParserState != null && options.LastParserState.Errors.Count > 0)
|
if (options.LastParserState != null && options.LastParserState.Errors.Count > 0)
|
||||||
{
|
{
|
||||||
var help = new HelpText();
|
var help = new HelpText();
|
||||||
var errors = help.RenderParsingErrorsText(options, 2); // indent with two spaces
|
var errors = help.RenderParsingErrorsText(options, 2); // indent with two spaces
|
||||||
Console.WriteLine("Jackett v" + Engine.ConfigService.GetVersion());
|
Console.WriteLine("Jackett v" + Engine.ConfigService.GetVersion());
|
||||||
Console.WriteLine("Switch error: " + errors);
|
Console.WriteLine("Switch error: " + errors);
|
||||||
Console.WriteLine("See --help for further details on switches.");
|
Console.WriteLine("See --help for further details on switches.");
|
||||||
Environment.ExitCode = 1;
|
Environment.ExitCode = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
var text = HelpText.AutoBuild(options, (HelpText current) => HelpText.DefaultParsingErrorsHandler(options, current));
|
var text = HelpText.AutoBuild(options, (HelpText current) => HelpText.DefaultParsingErrorsHandler(options, current));
|
||||||
text.Copyright = " ";
|
text.Copyright = " ";
|
||||||
text.Heading = "Jackett v" + Engine.ConfigService.GetVersion() + " options:";
|
text.Heading = "Jackett v" + Engine.ConfigService.GetVersion() + " options:";
|
||||||
Console.WriteLine(text);
|
Console.WriteLine(text);
|
||||||
Environment.ExitCode = 1;
|
Environment.ExitCode = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
if (options.ListenPublic && options.ListenPrivate)
|
if (options.ListenPublic && options.ListenPrivate)
|
||||||
{
|
{
|
||||||
Console.WriteLine("You can only use listen private OR listen publicly.");
|
Console.WriteLine("You can only use listen private OR listen publicly.");
|
||||||
Environment.ExitCode = 1;
|
Environment.ExitCode = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* ====== Options ===== */
|
/* ====== Options ===== */
|
||||||
|
|
||||||
// SSL Fix
|
// SSL Fix
|
||||||
Startup.DoSSLFix = options.SSLFix;
|
Startup.DoSSLFix = options.SSLFix;
|
||||||
|
|
||||||
// Use curl
|
// Use curl
|
||||||
if (options.Client != null)
|
if (options.Client != null)
|
||||||
Startup.ClientOverride = options.Client.ToLowerInvariant();
|
Startup.ClientOverride = options.Client.ToLowerInvariant();
|
||||||
|
|
||||||
// Use Proxy
|
// Use Proxy
|
||||||
if (options.ProxyConnection != null)
|
if (options.ProxyConnection != null)
|
||||||
{
|
{
|
||||||
Startup.ProxyConnection = options.ProxyConnection.ToLowerInvariant();
|
Startup.ProxyConnection = options.ProxyConnection.ToLowerInvariant();
|
||||||
}
|
Engine.Logger.Info("Proxy enabled. " + Startup.ProxyConnection);
|
||||||
// Logging
|
}
|
||||||
if (options.Logging)
|
// Logging
|
||||||
Startup.LogRequests = true;
|
if (options.Logging)
|
||||||
|
Startup.LogRequests = true;
|
||||||
// Tracing
|
|
||||||
if (options.Tracing)
|
// Tracing
|
||||||
Startup.TracingEnabled = true;
|
if (options.Tracing)
|
||||||
|
Startup.TracingEnabled = true;
|
||||||
// Log after the fact as using the logger will cause the options above to be used
|
|
||||||
|
// Log after the fact as using the logger will cause the options above to be used
|
||||||
if (options.Logging)
|
|
||||||
Engine.Logger.Info("Logging enabled.");
|
if (options.Logging)
|
||||||
|
Engine.Logger.Info("Logging enabled.");
|
||||||
if (options.Tracing)
|
|
||||||
Engine.Logger.Info("Tracing enabled.");
|
if (options.Tracing)
|
||||||
|
Engine.Logger.Info("Tracing enabled.");
|
||||||
if (options.SSLFix == true)
|
|
||||||
Engine.Logger.Info("SSL ECC workaround enabled.");
|
if (options.SSLFix == true)
|
||||||
else if (options.SSLFix == false)
|
Engine.Logger.Info("SSL ECC workaround enabled.");
|
||||||
Engine.Logger.Info("SSL ECC workaround has been disabled.");
|
else if (options.SSLFix == false)
|
||||||
|
Engine.Logger.Info("SSL ECC workaround has been disabled.");
|
||||||
// Ignore SSL errors on Curl
|
|
||||||
Startup.IgnoreSslErrors = options.IgnoreSslErrors;
|
// Ignore SSL errors on Curl
|
||||||
if (options.IgnoreSslErrors == true)
|
Startup.IgnoreSslErrors = options.IgnoreSslErrors;
|
||||||
{
|
if (options.IgnoreSslErrors == true)
|
||||||
Engine.Logger.Info("Curl will ignore SSL certificate errors.");
|
{
|
||||||
}
|
Engine.Logger.Info("Curl will ignore SSL certificate errors.");
|
||||||
|
}
|
||||||
/* ====== Actions ===== */
|
|
||||||
|
/* ====== Actions ===== */
|
||||||
// Install service
|
|
||||||
if (options.Install)
|
// Install service
|
||||||
{
|
if (options.Install)
|
||||||
Engine.ServiceConfig.Install();
|
{
|
||||||
return;
|
Engine.ServiceConfig.Install();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
// Uninstall service
|
|
||||||
if (options.Uninstall)
|
// Uninstall service
|
||||||
{
|
if (options.Uninstall)
|
||||||
Engine.Server.ReserveUrls(doInstall: false);
|
{
|
||||||
Engine.ServiceConfig.Uninstall();
|
Engine.Server.ReserveUrls(doInstall: false);
|
||||||
return;
|
Engine.ServiceConfig.Uninstall();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
// Reserve urls
|
|
||||||
if (options.ReserveUrls)
|
// Reserve urls
|
||||||
{
|
if (options.ReserveUrls)
|
||||||
Engine.Server.ReserveUrls(doInstall: true);
|
{
|
||||||
return;
|
Engine.Server.ReserveUrls(doInstall: true);
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
// Start Service
|
|
||||||
if (options.StartService)
|
// Start Service
|
||||||
{
|
if (options.StartService)
|
||||||
if (!Engine.ServiceConfig.ServiceRunning())
|
{
|
||||||
{
|
if (!Engine.ServiceConfig.ServiceRunning())
|
||||||
Engine.ServiceConfig.Start();
|
{
|
||||||
}
|
Engine.ServiceConfig.Start();
|
||||||
return;
|
}
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
// Stop Service
|
|
||||||
if (options.StopService)
|
// Stop Service
|
||||||
{
|
if (options.StopService)
|
||||||
if (Engine.ServiceConfig.ServiceRunning())
|
{
|
||||||
{
|
if (Engine.ServiceConfig.ServiceRunning())
|
||||||
Engine.ServiceConfig.Stop();
|
{
|
||||||
}
|
Engine.ServiceConfig.Stop();
|
||||||
return;
|
}
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
// Migrate settings
|
|
||||||
if (options.MigrateSettings)
|
// Migrate settings
|
||||||
{
|
if (options.MigrateSettings)
|
||||||
Engine.ConfigService.PerformMigration();
|
{
|
||||||
return;
|
Engine.ConfigService.PerformMigration();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Show Version
|
|
||||||
if (options.ShowVersion)
|
// Show Version
|
||||||
{
|
if (options.ShowVersion)
|
||||||
Console.WriteLine("Jackett v" + Engine.ConfigService.GetVersion());
|
{
|
||||||
return;
|
Console.WriteLine("Jackett v" + Engine.ConfigService.GetVersion());
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
/* ====== Overrides ===== */
|
|
||||||
|
/* ====== Overrides ===== */
|
||||||
// Override listen public
|
|
||||||
if (options.ListenPublic || options.ListenPrivate)
|
// Override listen public
|
||||||
{
|
if (options.ListenPublic || options.ListenPrivate)
|
||||||
if (Engine.Server.Config.AllowExternal != options.ListenPublic)
|
{
|
||||||
{
|
if (Engine.Server.Config.AllowExternal != options.ListenPublic)
|
||||||
Engine.Logger.Info("Overriding external access to " + options.ListenPublic);
|
{
|
||||||
Engine.Server.Config.AllowExternal = options.ListenPublic;
|
Engine.Logger.Info("Overriding external access to " + options.ListenPublic);
|
||||||
if (System.Environment.OSVersion.Platform != PlatformID.Unix)
|
Engine.Server.Config.AllowExternal = options.ListenPublic;
|
||||||
{
|
if (System.Environment.OSVersion.Platform != PlatformID.Unix)
|
||||||
if (ServerUtil.IsUserAdministrator())
|
{
|
||||||
{
|
if (ServerUtil.IsUserAdministrator())
|
||||||
Engine.Server.ReserveUrls(doInstall: true);
|
{
|
||||||
}
|
Engine.Server.ReserveUrls(doInstall: true);
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
Engine.Logger.Error("Unable to switch to public listening without admin rights.");
|
{
|
||||||
Environment.ExitCode = 1;
|
Engine.Logger.Error("Unable to switch to public listening without admin rights.");
|
||||||
return;
|
Environment.ExitCode = 1;
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Engine.Server.SaveConfig();
|
|
||||||
}
|
Engine.Server.SaveConfig();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Override port
|
|
||||||
if (options.Port != 0)
|
// Override port
|
||||||
{
|
if (options.Port != 0)
|
||||||
if (Engine.Server.Config.Port != options.Port)
|
{
|
||||||
{
|
if (Engine.Server.Config.Port != options.Port)
|
||||||
Engine.Logger.Info("Overriding port to " + options.Port);
|
{
|
||||||
Engine.Server.Config.Port = options.Port;
|
Engine.Logger.Info("Overriding port to " + options.Port);
|
||||||
if (System.Environment.OSVersion.Platform != PlatformID.Unix)
|
Engine.Server.Config.Port = options.Port;
|
||||||
{
|
if (System.Environment.OSVersion.Platform != PlatformID.Unix)
|
||||||
if (ServerUtil.IsUserAdministrator())
|
{
|
||||||
{
|
if (ServerUtil.IsUserAdministrator())
|
||||||
Engine.Server.ReserveUrls(doInstall: true);
|
{
|
||||||
}
|
Engine.Server.ReserveUrls(doInstall: true);
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
Engine.Logger.Error("Unable to switch ports when not running as administrator");
|
{
|
||||||
Environment.ExitCode = 1;
|
Engine.Logger.Error("Unable to switch ports when not running as administrator");
|
||||||
return;
|
Environment.ExitCode = 1;
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Engine.Server.SaveConfig();
|
|
||||||
}
|
Engine.Server.SaveConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Engine.Server.Initalize();
|
|
||||||
Engine.Server.Start();
|
Engine.Server.Initalize();
|
||||||
Engine.RunTime.Spin();
|
Engine.Server.Start();
|
||||||
Engine.Logger.Info("Server thread exit");
|
Engine.RunTime.Spin();
|
||||||
}
|
Engine.Logger.Info("Server thread exit");
|
||||||
catch (Exception e)
|
}
|
||||||
{
|
catch (Exception e)
|
||||||
Engine.Logger.Error(e, "Top level exception");
|
{
|
||||||
}
|
Engine.Logger.Error(e, "Top level exception");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace Jackett.Indexers
|
||||||
{
|
{
|
||||||
public class BitSoup : BaseIndexer, IIndexer
|
public class BitSoup : BaseIndexer, IIndexer
|
||||||
{
|
{
|
||||||
private string UseLink { get { return (this.configData.AlternateLink.Value != "" ? this.configData.AlternateLink.Value : SiteLink); } }
|
private string UseLink { get { return (this.configData.AlternateLink.Value != null && this.configData.AlternateLink.Value != "" ? this.configData.AlternateLink.Value : SiteLink); } }
|
||||||
private string BrowseUrl { get { return UseLink + "browse.php"; } }
|
private string BrowseUrl { get { return UseLink + "browse.php"; } }
|
||||||
private string LoginUrl { get { return UseLink + "takelogin.php"; } }
|
private string LoginUrl { get { return UseLink + "takelogin.php"; } }
|
||||||
private string LoginReferer { get { return UseLink + "login.php"; } }
|
private string LoginReferer { get { return UseLink + "login.php"; } }
|
||||||
|
@ -187,40 +187,13 @@ namespace Jackett.Indexers
|
||||||
var trackerCats = MapTorznabCapsToTrackers(query);
|
var trackerCats = MapTorznabCapsToTrackers(query);
|
||||||
var queryCollection = new NameValueCollection();
|
var queryCollection = new NameValueCollection();
|
||||||
|
|
||||||
|
|
||||||
|
queryCollection.Add("search", string.IsNullOrWhiteSpace(searchString)? "" : searchString);
|
||||||
if (!string.IsNullOrWhiteSpace(searchString))
|
queryCollection.Add("incldead", "0");
|
||||||
{
|
queryCollection.Add("cat", (trackerCats.Count < 2 ? "0" : trackerCats.ElementAt(0)));
|
||||||
queryCollection.Add("search", searchString);
|
searchUrl += "?" + queryCollection.GetQueryString();
|
||||||
queryCollection.Add("incldead", "0");
|
await ProcessPage(releases, searchUrl);
|
||||||
queryCollection.Add("cat", "0");
|
|
||||||
// Tracker cannot search multi categories
|
|
||||||
// so we either search "all"
|
|
||||||
// or do multiple searches
|
|
||||||
if (trackerCats.Count == 0)
|
|
||||||
{
|
|
||||||
searchUrl += "?" + queryCollection.GetQueryString();
|
|
||||||
await ProcessPage(releases, searchUrl);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
foreach (var cat in trackerCats)
|
|
||||||
{
|
|
||||||
queryCollection.Remove("cat");
|
|
||||||
queryCollection.Add("cat", cat);
|
|
||||||
searchUrl += "?" + queryCollection.GetQueryString();
|
|
||||||
await ProcessPage(releases, searchUrl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
queryCollection.Add("search", "");
|
|
||||||
queryCollection.Add("cat", "0");
|
|
||||||
searchUrl += "?" + queryCollection.GetQueryString();
|
|
||||||
await ProcessPage(releases, searchUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
return releases;
|
return releases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue