From f84cb6e334abff12b160c76548e71acb32558995 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Thu, 11 May 2023 16:48:47 +0300 Subject: [PATCH] animetorrents: add current time of day if date added is today --- src/Jackett.Common/Indexers/AnimeTorrents.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Jackett.Common/Indexers/AnimeTorrents.cs b/src/Jackett.Common/Indexers/AnimeTorrents.cs index ac90d16a5..d08d3fa1c 100644 --- a/src/Jackett.Common/Indexers/AnimeTorrents.cs +++ b/src/Jackett.Common/Indexers/AnimeTorrents.cs @@ -134,7 +134,9 @@ namespace Jackett.Common.Indexers }; if (configData.DownloadableOnly.Value) + { queryCollection.Set("dlable", "1"); + } searchUrl += "?" + queryCollection.GetQueryString(); @@ -153,7 +155,7 @@ namespace Jackett.Common.Indexers var dom = parser.ParseDocument(results); var rows = dom.QuerySelectorAll("table tr"); - foreach (var row in rows.Skip(1)) + foreach (var (row, index) in rows.Skip(1).Select((v, i) => (v, i))) { var downloadVolumeFactor = row.QuerySelector("img[alt=\"Gold Torrent\"]") != null ? 0 : row.QuerySelector("img[alt=\"Silver Torrent\"]") != null ? 0.5 : 1; @@ -185,6 +187,13 @@ namespace Jackett.Common.Indexers var categoryLink = row.QuerySelector("td:nth-of-type(1) a")?.GetAttribute("href") ?? string.Empty; var categoryId = ParseUtil.GetArgumentFromQueryString(categoryLink, "cat"); + var publishedDate = DateTime.ParseExact(row.QuerySelector("td:nth-of-type(5)").TextContent, "dd MMM yy", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); + + if (publishedDate.Date == DateTime.Today) + { + publishedDate = publishedDate.Date + DateTime.Now.TimeOfDay - TimeSpan.FromMinutes(index); + } + var release = new ReleaseInfo { Guid = new Uri(infoUrl), @@ -192,7 +201,7 @@ namespace Jackett.Common.Indexers Link = new Uri(downloadUrl), Title = title, Category = MapTrackerCatToNewznab(categoryId), - PublishDate = DateTime.ParseExact(row.QuerySelector("td:nth-of-type(5)").TextContent, "dd MMM yy", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal), + PublishDate = publishedDate, Size = ParseUtil.GetBytes(row.QuerySelector("td:nth-of-type(6)").TextContent.Trim()), Seeders = seeders, Peers = ParseUtil.CoerceInt(connections[1]) + seeders,