Compare commits

..

8 Commits

Author SHA1 Message Date
zone117x
012cec3a8b More console logging for non-windows 2015-04-22 18:37:25 -06:00
zone117x
5e2deb36c0 Fix relative WebContent path bug 2015-04-21 19:00:13 -06:00
zone117x
0cb0dbcb60 Fix for morethantv and some ssl issues 2015-04-21 18:57:04 -06:00
zone117x
75f823f671 Fix for bitmetv 2015-04-21 12:17:59 -06:00
zone117x
27ff36a3cc Likely fix for the non en-us systems having trouble 2015-04-20 18:27:58 -06:00
Matthew Little
ad9f116d33 Update README.md 2015-04-19 23:14:54 -06:00
zone117x
b2b25b9c2a Merge branch 'master' of https://github.com/zone117x/Jackett.git 2015-04-19 23:11:37 -06:00
zone117x
dce596ed1a Now works on Linux (headless), detailed logging, season searching 2015-04-19 23:10:50 -06:00
12 changed files with 101 additions and 30 deletions

View File

@@ -9,6 +9,9 @@ Currently [Sonarr](https://sonarr.tv/) is the only software that uses Torznab. [
### Download
Download in the [Releases page](https://github.com/zone117x/Jackett/releases)
### Supported Systems
Windows. Tested and working on Linux using Mono. Should also work on OSX.
### Supported Trackers
* [BitMeTV](http://www.bitmetv.org/)
* [MoreThan.tv](https://morethan.tv/)
@@ -16,7 +19,6 @@ Download in the [Releases page](https://github.com/zone117x/Jackett/releases)
* [Freshon](https://freshon.tv/)
* [IPTorrents](https://iptorrents.com/)
* [The Pirate Bay](https://thepiratebay.se/)
* [RARBG](https://rarbg.com)
### Additional Trackers

View File

@@ -89,8 +89,10 @@ namespace Jackett
{
var browseQuery = new TorznabQuery();
var results = await indexer.PerformQuery(browseQuery);
Program.LoggerInstance.Debug(string.Format("Found {0} releases from {1}", results.Length, indexer.DisplayName));
if (results.Length == 0)
throw new Exception("Found no results while trying to browse this tracker");
}
}

View File

@@ -155,11 +155,12 @@ namespace Jackett
release.Description = release.Title;
//"Tuesday, June 11th 2013 at 03:52:53 AM" to...
//"Tuesday June 11 2013 03 52 53 AM"
//"Tuesday June 11 2013 03:52:53 AM"
var timestamp = qDetailsCol.Children("font").Text().Trim() + " ";
var groups = new Regex(@"(.*?), (.*?) (.*?)th (.*?) at (.*?):(.*?):(.*?) (.*?) ").Match(timestamp).Groups;
var str = string.Join(" ", groups.Cast<Group>().Skip(1).Select(g => g.Value));
release.PublishDate = DateTime.ParseExact(str, "dddd MMMM d yyyy hh mm ss tt", CultureInfo.InvariantCulture);
var timeParts = new List<string>(timestamp.Replace(" at", "").Replace(",", "").Split(' '));
timeParts[2] = Regex.Replace(timeParts[2], "[^0-9.]", "");
var formattedTimeString = string.Join(" ", timeParts.ToArray()).Trim();
release.PublishDate = DateTime.ParseExact(formattedTimeString, "dddd MMMM d yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
release.Link = new Uri(BaseUrl + "/" + row.ChildElements.ElementAt(2).Cq().Children("a.index").Attr("href"));

View File

@@ -33,7 +33,7 @@ namespace Jackett.Indexers
public bool IsConfigured { get; private set; }
static string BaseUrl = "http://www.morethan.tv";
static string BaseUrl = "https://www.morethan.tv";
static string LoginUrl = BaseUrl + "/login.php";
@@ -66,7 +66,7 @@ namespace Jackett.Indexers
return Task.FromResult<ConfigurationData>(config);
}
public async Task ApplyConfiguration(Newtonsoft.Json.Linq.JToken configJson)
public async Task ApplyConfiguration(JToken configJson)
{
var config = new ConfigurationDataBasicLogin();

View File

@@ -57,6 +57,9 @@
<Reference Include="CsQuery">
<HintPath>..\packages\CsQuery.1.3.4\lib\net40\CsQuery.dll</HintPath>
</Reference>
<Reference Include="ModernHttpClient">
<HintPath>..\packages\modernhttpclient.2.3.0\lib\Portable-Net45+WinRT45+WP8+WPA81\ModernHttpClient.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>

View File

@@ -23,12 +23,18 @@ namespace Jackett
toolStripMenuItemAutoStart.Checked = AutoStart;
toolStripMenuItemAutoStart.CheckedChanged += toolStripMenuItemAutoStart_CheckedChanged;
toolStripMenuItemWebUI.Click += toolStripMenuItemWebUI_Click;
toolStripMenuItemShutdown.Click += toolStripMenuItemShutdown_Click;
if (Program.IsFirstRun)
AutoStart = true;
}
void toolStripMenuItemWebUI_Click(object sender, EventArgs e)
{
Process.Start("http://127.0.0.1:" + Server.Port);
}
void toolStripMenuItemShutdown_Click(object sender, EventArgs e)
{
Application.Exit();

View File

@@ -24,8 +24,12 @@ namespace Jackett
public static Logger LoggerInstance { get; private set; }
public static ManualResetEvent ExitEvent { get; private set; }
static void Main(string[] args)
{
ExitEvent = new ManualResetEvent(false);
try
{
if (!Directory.Exists(AppConfigDirectory))
@@ -33,6 +37,7 @@ namespace Jackett
IsFirstRun = true;
Directory.CreateDirectory(AppConfigDirectory);
}
Console.WriteLine("App config/log directory: " + AppConfigDirectory);
}
catch (Exception ex)
{
@@ -46,31 +51,49 @@ namespace Jackett
var logFile = new FileTarget();
logConfig.AddTarget("file", logFile);
logFile.FileName = Path.Combine(AppConfigDirectory, "log.txt");
logFile.Layout = "${longdate} ${level} ${message}";
logFile.Layout = "${longdate} ${level} ${message} \n ${exception:format=ToString}\n";
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);
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
var logAlert = new MessageBoxTarget();
logConfig.AddTarget("alert", logAlert);
logAlert.Layout = "${message}";
logAlert.Caption = "Alert";
var logAlertRule = new LoggingRule("*", LogLevel.Fatal, logAlert);
logConfig.LoggingRules.Add(logAlertRule);
}
var logConsole = new ConsoleTarget();
logConfig.AddTarget("console", logConsole);
logConsole.Layout = "${longdate} ${level} ${message} ${exception:format=ToString}";
var logConsoleRule = new LoggingRule("*", LogLevel.Debug, logConsole);
logConfig.LoggingRules.Add(logConsoleRule);
LogManager.Configuration = logConfig;
LoggerInstance = LogManager.GetCurrentClassLogger();
Task.Run(() =>
var serverTask = Task.Run(async () =>
{
ServerInstance = new Server();
ServerInstance.Start();
await ServerInstance.Start();
});
try
{
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
Application.Run(new Main());
}
catch (Exception ex)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
}
Console.WriteLine("Running in headless mode.");
Task.WaitAll(serverTask);
Console.WriteLine("Server thread exit");
}
static public void RestartAsAdmin()

View File

@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
@@ -25,6 +27,7 @@ namespace Jackett
string xmlDateFormat(DateTime dt)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
//Sat, 14 Mar 2015 17:10:42 -0400
var f = string.Format(@"{0:ddd, dd MMM yyyy HH:mm:ss }{1}", dt, string.Format("{0:zzz}", dt).Replace(":", ""));
return f;

View File

@@ -15,15 +15,19 @@ namespace Jackett
{
public class Server
{
int Port = 9117;
public const int Port = 9117;
HttpListener listener;
IndexerManager indexerManager;
WebApi webApi;
SonarrApi sonarrApi;
public Server()
{
// Allow all SSL.. sucks I know but mono on linux is having problems without it..
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
LoadApiKey();
indexerManager = new IndexerManager();
@@ -46,17 +50,17 @@ namespace Jackett
}
}
public async void Start()
public async Task Start()
{
Program.LoggerInstance.Info("Starting HTTP server...");
try
{
listener.Start();
Process.Start("http://127.0.0.1:" + Port);
}
catch (HttpListenerException ex)
{
Console.WriteLine("Server start exception: " + ex.ToString());
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",
@@ -75,10 +79,20 @@ namespace Jackett
}
catch (Exception ex)
{
Console.WriteLine("Server start exception: " + ex.ToString());
Program.LoggerInstance.ErrorException("Error: " + ex.Message, ex);
return;
}
Program.LoggerInstance.Info("Server started on port " + Port);
try
{
#if !DEBUG
Process.Start("http://127.0.0.1:" + Port);
#endif
}
catch (Exception) { }
while (true)
{
var context = await listener.GetContextAsync();
@@ -115,6 +129,7 @@ namespace Jackett
catch (Exception ex)
{
exception = ex;
Program.LoggerInstance.ErrorException(ex.Message + ex.ToString(), ex);
}
if (exception != null)
@@ -127,7 +142,11 @@ namespace Jackett
catch (Exception) { }
}
context.Response.Close();
try
{
context.Response.Close();
}
catch (Exception) { }
}
@@ -157,6 +176,8 @@ namespace Jackett
var releases = await indexer.PerformQuery(torznabQuery);
Program.LoggerInstance.Debug(string.Format("Found {0} releases from {1}", releases.Length, indexer.DisplayName));
var severUrl = string.Format("{0}://{1}:{2}/", context.Request.Url.Scheme, context.Request.Url.Host, context.Request.Url.Port);
var resultPage = new ResultPage(new ChannelInfo

View File

@@ -30,6 +30,8 @@ namespace Jackett
DateTime showDate;
if (DateTime.TryParseExact(string.Format("{0} {1}", Season, Episode), "yyyy MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out showDate))
episodeString = showDate.ToString("yyyy.MM.dd");
else if (string.IsNullOrEmpty(Episode))
episodeString = string.Format("S{0:00}", Season);
else
episodeString = string.Format("S{0:00}E{1:00}", Season, int.Parse(Episode));

View File

@@ -13,7 +13,7 @@ namespace Jackett
{
public class WebApi
{
static string WebContentFolder = "WebContent";
static string WebContentFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "WebContent");
static string[] StaticFiles = Directory.EnumerateFiles(WebContentFolder, "*", SearchOption.AllDirectories).ToArray();
public enum WebApiMethod
@@ -131,13 +131,20 @@ namespace Jackett
break;
}
JToken jsonReply = await handlerTask(context);
ReplyWithJson(context, jsonReply);
await ReplyWithJson(context, jsonReply, method.ToString());
}
async void ReplyWithJson(HttpListenerContext context, JToken json)
async Task ReplyWithJson(HttpListenerContext context, JToken json, string apiCall)
{
byte[] jsonBytes = Encoding.UTF8.GetBytes(json.ToString());
await context.Response.OutputStream.WriteAsync(jsonBytes, 0, jsonBytes.Length);
try
{
byte[] jsonBytes = Encoding.UTF8.GetBytes(json.ToString());
await context.Response.OutputStream.WriteAsync(jsonBytes, 0, jsonBytes.Length);
}
catch (Exception ex)
{
Console.WriteLine("Error writing json to stream for API call " + apiCall + Environment.NewLine + ex.ToString());
}
}
async Task<JToken> HandleTestSonarr(HttpListenerContext context)

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CsQuery" version="1.3.4" targetFramework="net451" />
<package id="modernhttpclient" version="2.3.0" targetFramework="net451" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
<package id="NLog" version="3.2.0.0" targetFramework="net451" />
</packages>