Organizational improvements and build warnings fixed

This commit is contained in:
unknown
2015-07-18 19:03:24 -06:00
parent 0c49540671
commit 03843c8833
28 changed files with 57 additions and 54 deletions

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 = DataUrl.BytesToDataUrl(((ImageItem)item).Value, "image/jpeg"); string dataUri = DataUrlUtil.BytesToDataUrl(((ImageItem)item).Value, "image/jpeg");
jObject["value"] = dataUri; jObject["value"] = dataUri;
break; break;
} }

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 = UnixTimestampToDateTime(dateNum); pubDate = DateTimeUtil.UnixTimestampToDateTime(dateNum);
var groupName = (string)r["groupName"]; var groupName = (string)r["groupName"];
@@ -225,13 +225,6 @@ 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,7 +23,6 @@ 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 = UnixTimestampToDateTime(dateNum); pubDate = DateTimeUtil.UnixTimestampToDateTime(dateNum);
pubDate = DateTime.SpecifyKind(pubDate, DateTimeKind.Utc).ToLocalTime(); pubDate = DateTime.SpecifyKind(pubDate, DateTimeKind.Utc).ToLocalTime();
} }
@@ -208,13 +208,6 @@ 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

@@ -81,18 +81,19 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="ApiKey.cs" /> <Compile Include="Utils\ApiKeyUtil.cs" />
<Compile Include="BrowserUtil.cs" /> <Compile Include="Utils\BrowserUtil.cs" />
<Compile Include="CachedResult.cs" /> <Compile Include="Torznab\CachedResult.cs" />
<Compile Include="ChannelInfo.cs" /> <Compile Include="Torznab\ChannelInfo.cs" />
<Compile Include="ConfigurationData.cs" /> <Compile Include="Configurations\ConfigurationData.cs" />
<Compile Include="ConfigurationDataBasicLogin.cs" /> <Compile Include="Configurations\ConfigurationDataBasicLogin.cs" />
<Compile Include="ConfigurationDataCookie.cs" /> <Compile Include="Configurations\ConfigurationDataCookie.cs" />
<Compile Include="ConfigurationDataUrl.cs" /> <Compile Include="Configurations\ConfigurationDataUrl.cs" />
<Compile Include="CookieContainerExtensions.cs" /> <Compile Include="Http\CookieContainerExtensions.cs" />
<Compile Include="DataUrl.cs" /> <Compile Include="Utils\DataUrl.cs" />
<Compile Include="ExceptionWithConfigData.cs" /> <Compile Include="Utils\DateTimeUtil.cs" />
<Compile Include="HttpClientExtensions.cs" /> <Compile Include="Configurations\ExceptionWithConfigData.cs" />
<Compile Include="Http\HttpClientExtensions.cs" />
<Compile Include="IndexerInterface.cs" /> <Compile Include="IndexerInterface.cs" />
<Compile Include="IndexerManager.cs" /> <Compile Include="IndexerManager.cs" />
<Compile Include="Indexers\BeyondHD.cs" /> <Compile Include="Indexers\BeyondHD.cs" />
@@ -115,13 +116,13 @@
<Compile Include="Indexers\TorrentLeech.cs" /> <Compile Include="Indexers\TorrentLeech.cs" />
<Compile Include="Indexers\TorrentShack.cs" /> <Compile Include="Indexers\TorrentShack.cs" />
<Compile Include="Indexers\Torrentz.cs" /> <Compile Include="Indexers\Torrentz.cs" />
<Compile Include="Main.cs"> <Compile Include="Windows\Main.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="Main.Designer.cs"> <Compile Include="Windows\Main.Designer.cs">
<DependentUpon>Main.cs</DependentUpon> <DependentUpon>Main.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="ParseUtil.cs" /> <Compile Include="Utils\ParseUtil.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs"> <Compile Include="Properties\Resources.Designer.cs">
@@ -129,13 +130,13 @@
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
</Compile> </Compile>
<Compile Include="ReleaseInfo.cs" /> <Compile Include="Torznab\ReleaseInfo.cs" />
<Compile Include="ResultPage.cs" /> <Compile Include="Torznab\ResultPage.cs" />
<Compile Include="Server.cs" /> <Compile Include="Server.cs" />
<Compile Include="ServerUtil.cs" /> <Compile Include="Utils\ServerUtil.cs" />
<Compile Include="TorznabQuery.cs" /> <Compile Include="Torznab\TorznabQuery.cs" />
<Compile Include="WebApi.cs" /> <Compile Include="WebApi.cs" />
<Compile Include="CurlHelper.cs" /> <Compile Include="Http\CurlHelper.cs" />
<Compile Include="Indexers\AlphaRatio.cs" /> <Compile Include="Indexers\AlphaRatio.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -149,7 +150,7 @@
<None Include="Resources\test.xml" /> <None Include="Resources\test.xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Main.resx"> <EmbeddedResource Include="Windows\Main.resx">
<DependentUpon>Main.cs</DependentUpon> <DependentUpon>Main.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">

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))
ApiKey.CurrentKey = File.ReadAllText(apiKeyFile).Trim(); ApiKeyUtil.CurrentKey = File.ReadAllText(apiKeyFile).Trim();
else else
{ {
ApiKey.CurrentKey = ApiKey.Generate(); ApiKeyUtil.CurrentKey = ApiKeyUtil.Generate();
File.WriteAllText(apiKeyFile, ApiKey.CurrentKey); File.WriteAllText(apiKeyFile, ApiKeyUtil.CurrentKey);
} }
} }
@@ -91,12 +91,12 @@ namespace Jackett
} }
else else
{ {
Program.LoggerInstance.FatalException("Failed to start HTTP server. " + ex.Message, ex); Program.LoggerInstance.Fatal(ex, "Failed to start HTTP server. " + ex.Message);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Program.LoggerInstance.ErrorException("Error starting HTTP server: " + ex.Message, ex); Program.LoggerInstance.Error(ex, "Error starting HTTP server: " + ex.Message);
return; return;
} }
@@ -114,13 +114,13 @@ namespace Jackett
} }
catch (ObjectDisposedException ex) catch (ObjectDisposedException ex)
{ {
Program.LoggerInstance.ErrorException("Critical error, HTTP listener was destroyed", ex); Program.LoggerInstance.Error(ex, "Critical error, HTTP listener was destroyed");
Process.GetCurrentProcess().Kill(); Process.GetCurrentProcess().Kill();
} }
catch (Exception ex) catch (Exception ex)
{ {
error = ex; error = ex;
Program.LoggerInstance.ErrorException("Error processing HTTP request", ex); Program.LoggerInstance.Error(ex, "Error processing HTTP request");
} }
if (error != null) if (error != null)
@@ -157,7 +157,7 @@ namespace Jackett
catch (Exception ex) catch (Exception ex)
{ {
exception = ex; exception = ex;
Program.LoggerInstance.ErrorException(ex.Message + ex.ToString(), ex); Program.LoggerInstance.Error(ex, ex.Message + ex.ToString());
} }
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

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

View File

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

View File

@@ -0,0 +1,19 @@
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"] = ApiKey.CurrentKey; jsonReply["api_key"] = ApiKeyUtil.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))