Undo Organizational improvements and build warnings fixed

This commit is contained in:
KZ 2015-07-19 14:56:48 +01:00
parent 01bf0b8144
commit f2be137836
27 changed files with 33 additions and 35 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -23,6 +23,7 @@ namespace Jackett.Indexers
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 static string LoginUrl = DefaultUrl + "/login.php";
private static string LoginPostUrl = DefaultUrl + "/login.php?returnto=index.php";
private const int MAXPAGES = 3;
CookieContainer cookies;

View File

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

View File

@ -41,11 +41,11 @@ namespace Jackett
{
var apiKeyFile = Path.Combine(Program.AppConfigDirectory, "api_key.txt");
if (File.Exists(apiKeyFile))
ApiKeyUtil.CurrentKey = File.ReadAllText(apiKeyFile).Trim();
ApiKey.CurrentKey = File.ReadAllText(apiKeyFile).Trim();
else
{
ApiKeyUtil.CurrentKey = ApiKeyUtil.Generate();
File.WriteAllText(apiKeyFile, ApiKeyUtil.CurrentKey);
ApiKey.CurrentKey = ApiKey.Generate();
File.WriteAllText(apiKeyFile, ApiKey.CurrentKey);
}
}
@ -91,12 +91,12 @@ namespace Jackett
}
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)
{
Program.LoggerInstance.Error(ex, "Error starting HTTP server: " + ex.Message);
Program.LoggerInstance.ErrorException("Error starting HTTP server: " + ex.Message, ex);
return;
}
@ -114,13 +114,13 @@ namespace Jackett
}
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();
}
catch (Exception ex)
{
error = ex;
Program.LoggerInstance.Error(ex, "Error processing HTTP request");
Program.LoggerInstance.ErrorException("Error processing HTTP request", ex);
}
if (error != null)
@ -157,7 +157,7 @@ namespace Jackett
catch (Exception ex)
{
exception = ex;
Program.LoggerInstance.Error(ex, ex.Message + ex.ToString());
Program.LoggerInstance.ErrorException(ex.Message + ex.ToString(), ex);
}
if (exception != null)
@ -202,10 +202,10 @@ namespace Jackett
var torznabQuery = TorznabQuery.FromHttpQuery(query);
/*if (torznabQuery.RageIDLookupEnabled && indexer.RequiresRageIDLookupDisabled)
if (torznabQuery.RageIDLookupEnabled && indexer.RequiresRageIDLookupDisabled)
{
throw new ArgumentException("This indexer requires RageID lookup disabled");
}*/
}
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
{
jsonReply["result"] = "success";
jsonReply["api_key"] = ApiKeyUtil.CurrentKey;
jsonReply["api_key"] = ApiKey.CurrentKey;
jsonReply["app_version"] = Assembly.GetExecutingAssembly().GetName().Version.ToString();
JArray items = new JArray();
foreach (var i in indexerManager.Indexers.OrderBy(_ => _.Key))