Skip to content

Commit 7af4f58

Browse files
committed
made the article keep age an initialization variable and removed some substack specific code
1 parent 87b1080 commit 7af4f58

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

RSSFeedAggregator/RSSFeedAggregator.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@ public class RSSFeedAggregator
1717
string _userAgent;
1818
string _paywallRemover;
1919
int _connectionTimeout;
20+
int _ArticleKeepAge;
2021
Dictionary<string, int> StarBotKeywords;
2122

2223
#region "Initialization"
2324
public void Initialize()
2425
{
2526
_connectionString = "ConnectionStringGoesHere";
2627
_userAgent = "UserAgentGoesHere";
27-
_connectionTimeout = 5000;
28+
_connectionTimeout = 5000; //(milliseconds) 5 second timeout
2829
_paywallRemover = "https://PaywallRemoverWebsite/proxy?q=";
30+
_ArticleKeepAge = -14; //(days) fetch articles with an age of 2 weeks maximum
2931
StarBotKeywords = InitKeywordTable();
3032
}
3133
#endregion
@@ -236,17 +238,13 @@ public void ReadTheFeed(string feedname, string feedurl, bool compareall, bool r
236238
linkuri = _paywallRemover + linkuri;
237239
}
238240
if (linkList.Contains(linkuri)) continue;
239-
if (!IsValidLastTwoWeeksDateTime(pubDateTime) ||
241+
if (!IsValidDateKeepRange(pubDateTime) ||
240242
linkuri.Length >= 451) continue;
241243
string titletext = "";
242244
string summarytext = "";
243245
if (i.Title.Text != null)
244246
{
245247
titletext = i.Title.Text;
246-
if (feedname == "Substack")
247-
{
248-
titletext = feed.Title.Text + " - " + titletext;
249-
}
250248
if (titletext.Length > 250)
251249
{
252250
titletext = titletext[..250];
@@ -283,11 +281,11 @@ public void ReadTheFeed(string feedname, string feedurl, bool compareall, bool r
283281
}
284282
}
285283

286-
public static bool IsValidLastTwoWeeksDateTime(DateTime? dateTime)
284+
public bool IsValidDateKeepRange(DateTime? dateTime)
287285
{
288286
if (dateTime == null) return false;
289287

290-
DateTime minValue = DateTime.Now.ToUniversalTime().AddDays(-14);
288+
DateTime minValue = DateTime.Now.ToUniversalTime().AddDays(_ArticleKeepAge);
291289
DateTime maxValue = DateTime.Now.ToUniversalTime();
292290

293291
return minValue <= dateTime.Value && maxValue >= dateTime.Value;

0 commit comments

Comments
 (0)