From e93e95a940878dd73af640a5c7713fc415a981c3 Mon Sep 17 00:00:00 2001 From: zone117x Date: Sat, 9 May 2015 12:53:28 -0600 Subject: [PATCH] Bug fixes for MoreThanTV and TorrentShack date parsing --- src/Jackett/Indexers/MoreThanTV.cs | 5 +++- src/Jackett/Indexers/TorrentShack.cs | 41 ++++++++++++++++------------ 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/Jackett/Indexers/MoreThanTV.cs b/src/Jackett/Indexers/MoreThanTV.cs index 8d61e9d40..00ab60379 100644 --- a/src/Jackett/Indexers/MoreThanTV.cs +++ b/src/Jackett/Indexers/MoreThanTV.cs @@ -166,8 +166,11 @@ namespace Jackett.Indexers var json = JObject.Parse(results); foreach (JObject r in json["response"]["results"]) { + DateTime pubDate = DateTime.MinValue; + double dateNum; + if (double.TryParse((string)r["groupTime"], out dateNum)) + pubDate = UnixTimestampToDateTime(dateNum); - var pubDate = UnixTimestampToDateTime(double.Parse((string)r["groupTime"])); var groupName = (string)r["groupName"]; if (r["torrents"] is JArray) diff --git a/src/Jackett/Indexers/TorrentShack.cs b/src/Jackett/Indexers/TorrentShack.cs index d4ced5277..cfc102b55 100644 --- a/src/Jackett/Indexers/TorrentShack.cs +++ b/src/Jackett/Indexers/TorrentShack.cs @@ -134,24 +134,29 @@ namespace Jackett.Indexers release.Link = new Uri(BaseUrl + "/" + qRow.Find(".torrent_handle_links > a").First().Attr("href")); var dateStr = qRow.Find(".time").Text().Trim(); - var dateParts = dateStr.Split(' '); - var dateValue = int.Parse(dateParts[0]); - TimeSpan ts = TimeSpan.Zero; - if (dateStr.Contains("sec")) - ts = TimeSpan.FromSeconds(dateValue); - else if (dateStr.Contains("min")) - ts = TimeSpan.FromMinutes(dateValue); - else if (dateStr.Contains("hour")) - ts = TimeSpan.FromHours(dateValue); - else if (dateStr.Contains("day")) - ts = TimeSpan.FromDays(dateValue); - else if (dateStr.Contains("week")) - ts = TimeSpan.FromDays(dateValue * 7); - else if (dateStr.Contains("month")) - ts = TimeSpan.FromDays(dateValue * 30); - else if (dateStr.Contains("year")) - ts = TimeSpan.FromDays(dateValue * 365); - release.PublishDate = DateTime.Now - ts; + if (dateStr.ToLower().Contains("just now")) + release.PublishDate = DateTime.Now; + else + { + var dateParts = dateStr.Split(' '); + var dateValue = int.Parse(dateParts[0]); + TimeSpan ts = TimeSpan.Zero; + if (dateStr.Contains("sec")) + ts = TimeSpan.FromSeconds(dateValue); + else if (dateStr.Contains("min")) + ts = TimeSpan.FromMinutes(dateValue); + else if (dateStr.Contains("hour")) + ts = TimeSpan.FromHours(dateValue); + else if (dateStr.Contains("day")) + ts = TimeSpan.FromDays(dateValue); + else if (dateStr.Contains("week")) + ts = TimeSpan.FromDays(dateValue * 7); + else if (dateStr.Contains("month")) + ts = TimeSpan.FromDays(dateValue * 30); + else if (dateStr.Contains("year")) + ts = TimeSpan.FromDays(dateValue * 365); + release.PublishDate = DateTime.Now - ts; + } var sizeStr = qRow.Find(".size")[0].ChildNodes[0].NodeValue.Trim(); var sizeParts = sizeStr.Split(' ');