diff --git a/src/Jackett/ConfigurationData.cs b/src/Jackett/Configurations/ConfigurationData.cs similarity index 96% rename from src/Jackett/ConfigurationData.cs rename to src/Jackett/Configurations/ConfigurationData.cs index 971698b0c..220df37d7 100644 --- a/src/Jackett/ConfigurationData.cs +++ b/src/Jackett/Configurations/ConfigurationData.cs @@ -57,7 +57,7 @@ namespace Jackett jObject["value"] = ((BoolItem)item).Value; break; case ItemType.DisplayImage: - string dataUri = DataUrl.BytesToDataUrl(((ImageItem)item).Value, "image/jpeg"); + string dataUri = DataUrlUtil.BytesToDataUrl(((ImageItem)item).Value, "image/jpeg"); jObject["value"] = dataUri; break; } diff --git a/src/Jackett/ConfigurationDataBasicLogin.cs b/src/Jackett/Configurations/ConfigurationDataBasicLogin.cs similarity index 100% rename from src/Jackett/ConfigurationDataBasicLogin.cs rename to src/Jackett/Configurations/ConfigurationDataBasicLogin.cs diff --git a/src/Jackett/ConfigurationDataCookie.cs b/src/Jackett/Configurations/ConfigurationDataCookie.cs similarity index 100% rename from src/Jackett/ConfigurationDataCookie.cs rename to src/Jackett/Configurations/ConfigurationDataCookie.cs diff --git a/src/Jackett/ConfigurationDataUrl.cs b/src/Jackett/Configurations/ConfigurationDataUrl.cs similarity index 100% rename from src/Jackett/ConfigurationDataUrl.cs rename to src/Jackett/Configurations/ConfigurationDataUrl.cs diff --git a/src/Jackett/ExceptionWithConfigData.cs b/src/Jackett/Configurations/ExceptionWithConfigData.cs similarity index 100% rename from src/Jackett/ExceptionWithConfigData.cs rename to src/Jackett/Configurations/ExceptionWithConfigData.cs diff --git a/src/Jackett/CookieContainerExtensions.cs b/src/Jackett/Http/CookieContainerExtensions.cs similarity index 100% rename from src/Jackett/CookieContainerExtensions.cs rename to src/Jackett/Http/CookieContainerExtensions.cs diff --git a/src/Jackett/CurlHelper.cs b/src/Jackett/Http/CurlHelper.cs similarity index 100% rename from src/Jackett/CurlHelper.cs rename to src/Jackett/Http/CurlHelper.cs diff --git a/src/Jackett/HttpClientExtensions.cs b/src/Jackett/Http/HttpClientExtensions.cs similarity index 100% rename from src/Jackett/HttpClientExtensions.cs rename to src/Jackett/Http/HttpClientExtensions.cs diff --git a/src/Jackett/Indexers/AlphaRatio.cs b/src/Jackett/Indexers/AlphaRatio.cs index 4967c3364..fe92ecbbd 100644 --- a/src/Jackett/Indexers/AlphaRatio.cs +++ b/src/Jackett/Indexers/AlphaRatio.cs @@ -188,7 +188,7 @@ namespace Jackett.Indexers DateTime pubDate = DateTime.MinValue; double dateNum; if (double.TryParse((string)r["groupTime"], out dateNum)) - pubDate = UnixTimestampToDateTime(dateNum); + pubDate = DateTimeUtil.UnixTimestampToDateTime(dateNum); var groupName = (string)r["groupName"]; @@ -225,13 +225,6 @@ 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 Download(Uri link) { if (Program.IsWindows) diff --git a/src/Jackett/Indexers/HDTorrents.cs b/src/Jackett/Indexers/HDTorrents.cs index b14945c7f..991d78d7e 100644 --- a/src/Jackett/Indexers/HDTorrents.cs +++ b/src/Jackett/Indexers/HDTorrents.cs @@ -23,7 +23,6 @@ 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; diff --git a/src/Jackett/Indexers/MoreThanTV.cs b/src/Jackett/Indexers/MoreThanTV.cs index b742192f4..82488708e 100644 --- a/src/Jackett/Indexers/MoreThanTV.cs +++ b/src/Jackett/Indexers/MoreThanTV.cs @@ -169,7 +169,7 @@ namespace Jackett.Indexers double dateNum; if (double.TryParse((string)r["groupTime"], out dateNum)) { - pubDate = UnixTimestampToDateTime(dateNum); + pubDate = DateTimeUtil.UnixTimestampToDateTime(dateNum); pubDate = DateTime.SpecifyKind(pubDate, DateTimeKind.Utc).ToLocalTime(); } @@ -208,13 +208,6 @@ 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 Download(Uri link) { if (Program.IsWindows) diff --git a/src/Jackett/Jackett.csproj b/src/Jackett/Jackett.csproj index baeba57d8..df0fdba29 100644 --- a/src/Jackett/Jackett.csproj +++ b/src/Jackett/Jackett.csproj @@ -81,18 +81,19 @@ - - - - - - - - - - - - + + + + + + + + + + + + + @@ -115,13 +116,13 @@ - + Form - + Main.cs - + @@ -129,13 +130,13 @@ True Resources.resx - - + + - - + + - + @@ -149,7 +150,7 @@ - + Main.cs diff --git a/src/Jackett/Server.cs b/src/Jackett/Server.cs index 598f992c6..ea70edf3c 100644 --- a/src/Jackett/Server.cs +++ b/src/Jackett/Server.cs @@ -41,11 +41,11 @@ namespace Jackett { var apiKeyFile = Path.Combine(Program.AppConfigDirectory, "api_key.txt"); if (File.Exists(apiKeyFile)) - ApiKey.CurrentKey = File.ReadAllText(apiKeyFile).Trim(); + ApiKeyUtil.CurrentKey = File.ReadAllText(apiKeyFile).Trim(); else { - ApiKey.CurrentKey = ApiKey.Generate(); - File.WriteAllText(apiKeyFile, ApiKey.CurrentKey); + ApiKeyUtil.CurrentKey = ApiKeyUtil.Generate(); + File.WriteAllText(apiKeyFile, ApiKeyUtil.CurrentKey); } } @@ -91,12 +91,12 @@ namespace Jackett } 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) { - Program.LoggerInstance.ErrorException("Error starting HTTP server: " + ex.Message, ex); + Program.LoggerInstance.Error(ex, "Error starting HTTP server: " + ex.Message); return; } @@ -114,13 +114,13 @@ namespace Jackett } 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(); } catch (Exception ex) { error = ex; - Program.LoggerInstance.ErrorException("Error processing HTTP request", ex); + Program.LoggerInstance.Error(ex, "Error processing HTTP request"); } if (error != null) @@ -157,7 +157,7 @@ namespace Jackett catch (Exception ex) { exception = ex; - Program.LoggerInstance.ErrorException(ex.Message + ex.ToString(), ex); + Program.LoggerInstance.Error(ex, ex.Message + ex.ToString()); } 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); diff --git a/src/Jackett/CachedResult.cs b/src/Jackett/Torznab/CachedResult.cs similarity index 100% rename from src/Jackett/CachedResult.cs rename to src/Jackett/Torznab/CachedResult.cs diff --git a/src/Jackett/ChannelInfo.cs b/src/Jackett/Torznab/ChannelInfo.cs similarity index 100% rename from src/Jackett/ChannelInfo.cs rename to src/Jackett/Torznab/ChannelInfo.cs diff --git a/src/Jackett/ReleaseInfo.cs b/src/Jackett/Torznab/ReleaseInfo.cs similarity index 100% rename from src/Jackett/ReleaseInfo.cs rename to src/Jackett/Torznab/ReleaseInfo.cs diff --git a/src/Jackett/ResultPage.cs b/src/Jackett/Torznab/ResultPage.cs similarity index 100% rename from src/Jackett/ResultPage.cs rename to src/Jackett/Torznab/ResultPage.cs diff --git a/src/Jackett/TorznabQuery.cs b/src/Jackett/Torznab/TorznabQuery.cs similarity index 100% rename from src/Jackett/TorznabQuery.cs rename to src/Jackett/Torznab/TorznabQuery.cs diff --git a/src/Jackett/ApiKey.cs b/src/Jackett/Utils/ApiKeyUtil.cs similarity index 95% rename from src/Jackett/ApiKey.cs rename to src/Jackett/Utils/ApiKeyUtil.cs index 86848899a..b6b449aab 100644 --- a/src/Jackett/ApiKey.cs +++ b/src/Jackett/Utils/ApiKeyUtil.cs @@ -7,9 +7,8 @@ using System.Threading.Tasks; namespace Jackett { - public class ApiKey + public static class ApiKeyUtil { - public static string CurrentKey; const string chars = "abcdefghijklmnopqrstuvwxyz0123456789"; diff --git a/src/Jackett/BrowserUtil.cs b/src/Jackett/Utils/BrowserUtil.cs similarity index 100% rename from src/Jackett/BrowserUtil.cs rename to src/Jackett/Utils/BrowserUtil.cs diff --git a/src/Jackett/DataUrl.cs b/src/Jackett/Utils/DataUrl.cs similarity index 94% rename from src/Jackett/DataUrl.cs rename to src/Jackett/Utils/DataUrl.cs index 339858836..dff8bf509 100644 --- a/src/Jackett/DataUrl.cs +++ b/src/Jackett/Utils/DataUrl.cs @@ -8,9 +8,8 @@ using System.Web; namespace Jackett { - public class DataUrl + public static class DataUrlUtil { - public static string ReadFileToDataUrl(string file) { string mime = MimeMapping.GetMimeMapping(file); diff --git a/src/Jackett/Utils/DateTimeUtil.cs b/src/Jackett/Utils/DateTimeUtil.cs new file mode 100644 index 000000000..7e5989661 --- /dev/null +++ b/src/Jackett/Utils/DateTimeUtil.cs @@ -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); + } + + } +} diff --git a/src/Jackett/ParseUtil.cs b/src/Jackett/Utils/ParseUtil.cs similarity index 100% rename from src/Jackett/ParseUtil.cs rename to src/Jackett/Utils/ParseUtil.cs diff --git a/src/Jackett/ServerUtil.cs b/src/Jackett/Utils/ServerUtil.cs similarity index 100% rename from src/Jackett/ServerUtil.cs rename to src/Jackett/Utils/ServerUtil.cs diff --git a/src/Jackett/WebApi.cs b/src/Jackett/WebApi.cs index 2f56a5d58..5c1d70ed5 100644 --- a/src/Jackett/WebApi.cs +++ b/src/Jackett/WebApi.cs @@ -211,7 +211,7 @@ namespace Jackett try { jsonReply["result"] = "success"; - jsonReply["api_key"] = ApiKey.CurrentKey; + jsonReply["api_key"] = ApiKeyUtil.CurrentKey; jsonReply["app_version"] = Assembly.GetExecutingAssembly().GetName().Version.ToString(); JArray items = new JArray(); foreach (var i in indexerManager.Indexers.OrderBy(_ => _.Key)) diff --git a/src/Jackett/Main.Designer.cs b/src/Jackett/Windows/Main.Designer.cs similarity index 100% rename from src/Jackett/Main.Designer.cs rename to src/Jackett/Windows/Main.Designer.cs diff --git a/src/Jackett/Main.cs b/src/Jackett/Windows/Main.cs similarity index 100% rename from src/Jackett/Main.cs rename to src/Jackett/Windows/Main.cs diff --git a/src/Jackett/Main.resx b/src/Jackett/Windows/Main.resx similarity index 100% rename from src/Jackett/Main.resx rename to src/Jackett/Windows/Main.resx