Undo Organizational improvements and build warnings fixed

This commit is contained in:
Kayomani
2015-07-19 14:56:48 +01:00
parent ce7c5fdd48
commit 32ef46501c
27 changed files with 33 additions and 35 deletions

View File

@@ -7,8 +7,9 @@ using System.Threading.Tasks;
namespace Jackett namespace Jackett
{ {
public static class ApiKeyUtil public class ApiKey
{ {
public static string CurrentKey; public static string CurrentKey;
const string chars = "abcdefghijklmnopqrstuvwxyz0123456789"; const string chars = "abcdefghijklmnopqrstuvwxyz0123456789";

View File

@@ -57,7 +57,7 @@ namespace Jackett
jObject["value"] = ((BoolItem)item).Value; jObject["value"] = ((BoolItem)item).Value;
break; break;
case ItemType.DisplayImage: case ItemType.DisplayImage:
string dataUri = DataUrlUtil.BytesToDataUrl(((ImageItem)item).Value, "image/jpeg"); string dataUri = DataUrl.BytesToDataUrl(((ImageItem)item).Value, "image/jpeg");
jObject["value"] = dataUri; jObject["value"] = dataUri;
break; break;
} }

View File

@@ -8,8 +8,9 @@ using System.Web;
namespace Jackett namespace Jackett
{ {
public static class DataUrlUtil public class DataUrl
{ {
public static string ReadFileToDataUrl(string file) public static string ReadFileToDataUrl(string file)
{ {
string mime = MimeMapping.GetMimeMapping(file); string mime = MimeMapping.GetMimeMapping(file);

View File

@@ -188,7 +188,7 @@ namespace Jackett.Indexers
DateTime pubDate = DateTime.MinValue; DateTime pubDate = DateTime.MinValue;
double dateNum; double dateNum;
if (double.TryParse((string)r["groupTime"], out dateNum)) if (double.TryParse((string)r["groupTime"], out dateNum))
pubDate = DateTimeUtil.UnixTimestampToDateTime(dateNum); pubDate = UnixTimestampToDateTime(dateNum);
var groupName = (string)r["groupName"]; var groupName = (string)r["groupName"];
@@ -225,6 +225,13 @@ namespace Jackett.Indexers
return releases.ToArray(); 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 async Task<byte[]> Download(Uri link) public async Task<byte[]> Download(Uri link)
{ {
if (Program.IsWindows) if (Program.IsWindows)

View File

@@ -23,6 +23,7 @@ namespace Jackett.Indexers
static string chromeUserAgent = BrowserUtil.ChromeUserAgent; static string chromeUserAgent = BrowserUtil.ChromeUserAgent;
private string SearchUrl = DefaultUrl + "/torrents.php?search={0}&active=1&options=0&category%5B%5D=59&category%5B%5D=60&category%5B%5D=30&category%5B%5D=38&page={1}"; private string SearchUrl = DefaultUrl + "/torrents.php?search={0}&active=1&options=0&category%5B%5D=59&category%5B%5D=60&category%5B%5D=30&category%5B%5D=38&page={1}";
private static string LoginUrl = DefaultUrl + "/login.php"; private static string LoginUrl = DefaultUrl + "/login.php";
private static string LoginPostUrl = DefaultUrl + "/login.php?returnto=index.php";
private const int MAXPAGES = 3; private const int MAXPAGES = 3;
CookieContainer cookies; CookieContainer cookies;

View File

@@ -169,7 +169,7 @@ namespace Jackett.Indexers
double dateNum; double dateNum;
if (double.TryParse((string)r["groupTime"], out dateNum)) if (double.TryParse((string)r["groupTime"], out dateNum))
{ {
pubDate = DateTimeUtil.UnixTimestampToDateTime(dateNum); pubDate = UnixTimestampToDateTime(dateNum);
pubDate = DateTime.SpecifyKind(pubDate, DateTimeKind.Utc).ToLocalTime(); pubDate = DateTime.SpecifyKind(pubDate, DateTimeKind.Utc).ToLocalTime();
} }
@@ -208,6 +208,13 @@ namespace Jackett.Indexers
return releases.ToArray(); 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 async Task<byte[]> Download(Uri link) public async Task<byte[]> Download(Uri link)
{ {
if (Program.IsWindows) if (Program.IsWindows)

View File

@@ -41,11 +41,11 @@ namespace Jackett
{ {
var apiKeyFile = Path.Combine(Program.AppConfigDirectory, "api_key.txt"); var apiKeyFile = Path.Combine(Program.AppConfigDirectory, "api_key.txt");
if (File.Exists(apiKeyFile)) if (File.Exists(apiKeyFile))
ApiKeyUtil.CurrentKey = File.ReadAllText(apiKeyFile).Trim(); ApiKey.CurrentKey = File.ReadAllText(apiKeyFile).Trim();
else else
{ {
ApiKeyUtil.CurrentKey = ApiKeyUtil.Generate(); ApiKey.CurrentKey = ApiKey.Generate();
File.WriteAllText(apiKeyFile, ApiKeyUtil.CurrentKey); File.WriteAllText(apiKeyFile, ApiKey.CurrentKey);
} }
} }
@@ -91,12 +91,12 @@ namespace Jackett
} }
else else
{ {
Program.LoggerInstance.Fatal(ex, "Failed to start HTTP server. " + ex.Message); Program.LoggerInstance.FatalException("Failed to start HTTP server. " + ex.Message, ex);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Program.LoggerInstance.Error(ex, "Error starting HTTP server: " + ex.Message); Program.LoggerInstance.ErrorException("Error starting HTTP server: " + ex.Message, ex);
return; return;
} }
@@ -114,13 +114,13 @@ namespace Jackett
} }
catch (ObjectDisposedException ex) catch (ObjectDisposedException ex)
{ {
Program.LoggerInstance.Error(ex, "Critical error, HTTP listener was destroyed"); Program.LoggerInstance.ErrorException("Critical error, HTTP listener was destroyed", ex);
Process.GetCurrentProcess().Kill(); Process.GetCurrentProcess().Kill();
} }
catch (Exception ex) catch (Exception ex)
{ {
error = ex; error = ex;
Program.LoggerInstance.Error(ex, "Error processing HTTP request"); Program.LoggerInstance.ErrorException("Error processing HTTP request", ex);
} }
if (error != null) if (error != null)
@@ -157,7 +157,7 @@ namespace Jackett
catch (Exception ex) catch (Exception ex)
{ {
exception = ex; exception = ex;
Program.LoggerInstance.Error(ex, ex.Message + ex.ToString()); Program.LoggerInstance.ErrorException(ex.Message + ex.ToString(), ex);
} }
if (exception != null) if (exception != null)
@@ -202,10 +202,10 @@ namespace Jackett
var torznabQuery = TorznabQuery.FromHttpQuery(query); var torznabQuery = TorznabQuery.FromHttpQuery(query);
/*if (torznabQuery.RageIDLookupEnabled && indexer.RequiresRageIDLookupDisabled) if (torznabQuery.RageIDLookupEnabled && indexer.RequiresRageIDLookupDisabled)
{ {
throw new ArgumentException("This indexer requires RageID lookup disabled"); throw new ArgumentException("This indexer requires RageID lookup disabled");
}*/ }
var releases = await indexer.PerformQuery(torznabQuery); var releases = await indexer.PerformQuery(torznabQuery);

View File

@@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jackett
{
public static class DateTimeUtil
{
public 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);
}
}
}

View File

@@ -211,7 +211,7 @@ namespace Jackett
try try
{ {
jsonReply["result"] = "success"; jsonReply["result"] = "success";
jsonReply["api_key"] = ApiKeyUtil.CurrentKey; jsonReply["api_key"] = ApiKey.CurrentKey;
jsonReply["app_version"] = Assembly.GetExecutingAssembly().GetName().Version.ToString(); jsonReply["app_version"] = Assembly.GetExecutingAssembly().GetName().Version.ToString();
JArray items = new JArray(); JArray items = new JArray();
foreach (var i in indexerManager.Indexers.OrderBy(_ => _.Key)) foreach (var i in indexerManager.Indexers.OrderBy(_ => _.Key))