diff --git a/src/Jackett/Utils/ApiKeyUtil.cs b/src/Jackett/ApiKey.cs similarity index 95% rename from src/Jackett/Utils/ApiKeyUtil.cs rename to src/Jackett/ApiKey.cs index b6b449aab..86848899a 100644 --- a/src/Jackett/Utils/ApiKeyUtil.cs +++ b/src/Jackett/ApiKey.cs @@ -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"; diff --git a/src/Jackett/Utils/BrowserUtil.cs b/src/Jackett/BrowserUtil.cs similarity index 100% rename from src/Jackett/Utils/BrowserUtil.cs rename to src/Jackett/BrowserUtil.cs diff --git a/src/Jackett/Torznab/CachedResult.cs b/src/Jackett/CachedResult.cs similarity index 100% rename from src/Jackett/Torznab/CachedResult.cs rename to src/Jackett/CachedResult.cs diff --git a/src/Jackett/Torznab/ChannelInfo.cs b/src/Jackett/ChannelInfo.cs similarity index 100% rename from src/Jackett/Torznab/ChannelInfo.cs rename to src/Jackett/ChannelInfo.cs diff --git a/src/Jackett/Configurations/ConfigurationData.cs b/src/Jackett/ConfigurationData.cs similarity index 96% rename from src/Jackett/Configurations/ConfigurationData.cs rename to src/Jackett/ConfigurationData.cs index 220df37d7..971698b0c 100644 --- a/src/Jackett/Configurations/ConfigurationData.cs +++ b/src/Jackett/ConfigurationData.cs @@ -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; } diff --git a/src/Jackett/Configurations/ConfigurationDataBasicLogin.cs b/src/Jackett/ConfigurationDataBasicLogin.cs similarity index 100% rename from src/Jackett/Configurations/ConfigurationDataBasicLogin.cs rename to src/Jackett/ConfigurationDataBasicLogin.cs diff --git a/src/Jackett/Configurations/ConfigurationDataCookie.cs b/src/Jackett/ConfigurationDataCookie.cs similarity index 100% rename from src/Jackett/Configurations/ConfigurationDataCookie.cs rename to src/Jackett/ConfigurationDataCookie.cs diff --git a/src/Jackett/Configurations/ConfigurationDataUrl.cs b/src/Jackett/ConfigurationDataUrl.cs similarity index 100% rename from src/Jackett/Configurations/ConfigurationDataUrl.cs rename to src/Jackett/ConfigurationDataUrl.cs diff --git a/src/Jackett/Http/CookieContainerExtensions.cs b/src/Jackett/CookieContainerExtensions.cs similarity index 100% rename from src/Jackett/Http/CookieContainerExtensions.cs rename to src/Jackett/CookieContainerExtensions.cs diff --git a/src/Jackett/Http/CurlHelper.cs b/src/Jackett/CurlHelper.cs similarity index 100% rename from src/Jackett/Http/CurlHelper.cs rename to src/Jackett/CurlHelper.cs diff --git a/src/Jackett/Utils/DataUrl.cs b/src/Jackett/DataUrl.cs similarity index 94% rename from src/Jackett/Utils/DataUrl.cs rename to src/Jackett/DataUrl.cs index dff8bf509..339858836 100644 --- a/src/Jackett/Utils/DataUrl.cs +++ b/src/Jackett/DataUrl.cs @@ -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); diff --git a/src/Jackett/Configurations/ExceptionWithConfigData.cs b/src/Jackett/ExceptionWithConfigData.cs similarity index 100% rename from src/Jackett/Configurations/ExceptionWithConfigData.cs rename to src/Jackett/ExceptionWithConfigData.cs diff --git a/src/Jackett/Http/HttpClientExtensions.cs b/src/Jackett/HttpClientExtensions.cs similarity index 100% rename from src/Jackett/Http/HttpClientExtensions.cs rename to src/Jackett/HttpClientExtensions.cs diff --git a/src/Jackett/Indexers/AlphaRatio.cs b/src/Jackett/Indexers/AlphaRatio.cs index fe92ecbbd..4967c3364 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 = 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 Download(Uri link) { if (Program.IsWindows) diff --git a/src/Jackett/Indexers/HDTorrents.cs b/src/Jackett/Indexers/HDTorrents.cs index 991d78d7e..b14945c7f 100644 --- a/src/Jackett/Indexers/HDTorrents.cs +++ b/src/Jackett/Indexers/HDTorrents.cs @@ -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; diff --git a/src/Jackett/Indexers/MoreThanTV.cs b/src/Jackett/Indexers/MoreThanTV.cs index 82488708e..b742192f4 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 = 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 Download(Uri link) { if (Program.IsWindows) diff --git a/src/Jackett/Windows/Main.Designer.cs b/src/Jackett/Main.Designer.cs similarity index 100% rename from src/Jackett/Windows/Main.Designer.cs rename to src/Jackett/Main.Designer.cs diff --git a/src/Jackett/Windows/Main.cs b/src/Jackett/Main.cs similarity index 100% rename from src/Jackett/Windows/Main.cs rename to src/Jackett/Main.cs diff --git a/src/Jackett/Windows/Main.resx b/src/Jackett/Main.resx similarity index 100% rename from src/Jackett/Windows/Main.resx rename to src/Jackett/Main.resx diff --git a/src/Jackett/Utils/ParseUtil.cs b/src/Jackett/ParseUtil.cs similarity index 100% rename from src/Jackett/Utils/ParseUtil.cs rename to src/Jackett/ParseUtil.cs diff --git a/src/Jackett/Torznab/ReleaseInfo.cs b/src/Jackett/ReleaseInfo.cs similarity index 100% rename from src/Jackett/Torznab/ReleaseInfo.cs rename to src/Jackett/ReleaseInfo.cs diff --git a/src/Jackett/Torznab/ResultPage.cs b/src/Jackett/ResultPage.cs similarity index 100% rename from src/Jackett/Torznab/ResultPage.cs rename to src/Jackett/ResultPage.cs diff --git a/src/Jackett/Server.cs b/src/Jackett/Server.cs index ea70edf3c..598f992c6 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)) - 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); diff --git a/src/Jackett/Utils/ServerUtil.cs b/src/Jackett/ServerUtil.cs similarity index 100% rename from src/Jackett/Utils/ServerUtil.cs rename to src/Jackett/ServerUtil.cs diff --git a/src/Jackett/Torznab/TorznabQuery.cs b/src/Jackett/TorznabQuery.cs similarity index 100% rename from src/Jackett/Torznab/TorznabQuery.cs rename to src/Jackett/TorznabQuery.cs diff --git a/src/Jackett/Utils/DateTimeUtil.cs b/src/Jackett/Utils/DateTimeUtil.cs deleted file mode 100644 index 7e5989661..000000000 --- a/src/Jackett/Utils/DateTimeUtil.cs +++ /dev/null @@ -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); - } - - } -} diff --git a/src/Jackett/WebApi.cs b/src/Jackett/WebApi.cs index 5c1d70ed5..2f56a5d58 100644 --- a/src/Jackett/WebApi.cs +++ b/src/Jackett/WebApi.cs @@ -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))