13 Commits

Author SHA1 Message Date
Richard Mwewa
1f3d8f41eb Merge pull request #5 from bellingcat/dev
Dev
2023-08-08 07:15:29 +02:00
Richard Mwewa
4ac58f0fc4 Update README.md 2023-08-08 07:10:13 +02:00
Richard Mwewa
7696dd923a Update __main.py
Changed layout and applied dark mode to the "Right Click" menu
2023-08-08 07:08:58 +02:00
Richard Mwewa
45b82e57ac Update pyproject.toml
Changed layout and applied dark mode to the "Right Click" Menu
2023-08-08 07:07:52 +02:00
Richard Mwewa
6d6e616640 Update README.md 2023-08-08 07:06:52 +02:00
Richard Mwewa
4ba402a129 Add files via upload
1.5.0.0
2023-08-08 07:00:32 +02:00
Richard Mwewa
52d36baae2 Delete RPST GUI directory 2023-08-07 16:29:00 +02:00
Richard Mwewa
1086ba1db1 Merge pull request #4 from bellingcat/dev
Dev
2023-08-07 02:32:17 +02:00
Richard Mwewa
d8919b4357 Update __main.py
Added dark mode to the About box.
2023-08-07 02:31:20 +02:00
Richard Mwewa
8952c7910b Update README.md 2023-08-07 02:29:28 +02:00
Richard Mwewa
5d144fcd00 Add files via upload
Added dark mode to the About box
2023-08-07 02:27:51 +02:00
Richard Mwewa
4c86206d0f Update pyproject.toml
Added dark mode to the About Form
2023-08-07 02:25:06 +02:00
Richard Mwewa
6f77623681 Update README.md 2023-08-07 02:24:04 +02:00
25 changed files with 1735 additions and 1413 deletions

View File

@@ -1,11 +1,9 @@
# RPST (Reddit Post Scraping Tool)
Given a subreddit name and a keyword, this script will return all posts from a specified listing (default is 'top') that contain the provided keyword.
Given a subreddit name and a keyword, RPST will return all posts from a specified listing (default is 'top') that contain the provided keyword.
[![Upload Python Package](https://github.com/rly0nheart/reddit-post-scraping-tool/actions/workflows/python-publish.yml/badge.svg)](https://github.com/rly0nheart/reddit-post-scraping-tool/actions/workflows/python-publish.yml) [![CodeQL](https://github.com/rly0nheart/reddit-post-scraping-tool/actions/workflows/codeql.yml/badge.svg)](https://github.com/rly0nheart/reddit-post-scraping-tool/actions/workflows/codeql.yml) ![.Net](https://img.shields.io/badge/.NET-5C2D91?style=flat&logo=.net&logoColor=white) ![Python](https://img.shields.io/badge/python-3670A0?style=flat&logo=python&logoColor=ffdd54)
![2023-08-06_04-30](https://github.com/bellingcat/reddit-post-scraping-tool/assets/74001397/e924ec32-8786-41ab-af59-bd5fca0cdb57)
![2023-08-06_04-32](https://github.com/bellingcat/reddit-post-scraping-tool/assets/74001397/04d6de20-2e02-4dea-a1cc-30c611802acf)
![2023-08-08_07-04](https://github.com/bellingcat/reddit-post-scraping-tool/assets/74001397/10d91093-7b24-4de9-9f02-454b842d6b8e)
![2023-08-08_07-04_1](https://github.com/bellingcat/reddit-post-scraping-tool/assets/74001397/268a4c0e-d849-49a3-94ba-296d193774e1)
# ✅ Features

View File

@@ -23,99 +23,103 @@ Partial Class AboutBox
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Dim resources As ComponentModel.ComponentResourceManager = New ComponentModel.ComponentResourceManager(GetType(AboutBox))
PictureBox1 = New PictureBox()
PictureBoxLogo = New PictureBox()
LabelProgramName = New Label()
LabelProgramDescription = New Label()
LabelVersion = New Label()
LinkLabelReadtheWiki = New LinkLabel()
Panel1 = New Panel()
LicenseRichTextBox = New RichTextBox()
LicenseLabel = New Label()
ProgramNameLabel = New Label()
DescriptionLabel = New Label()
VersionLabel = New Label()
WikiLinkLabel = New LinkLabel()
CType(PictureBox1, ComponentModel.ISupportInitialize).BeginInit()
CType(PictureBoxLogo, ComponentModel.ISupportInitialize).BeginInit()
Panel1.SuspendLayout()
SuspendLayout()
'
' PictureBox1
' PictureBoxLogo
'
PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), Image)
PictureBox1.Location = New Point(28, 38)
PictureBox1.Name = "PictureBox1"
PictureBox1.Size = New Size(82, 88)
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
PictureBox1.TabIndex = 0
PictureBox1.TabStop = False
PictureBoxLogo.BackColor = Color.Transparent
PictureBoxLogo.Image = CType(resources.GetObject("PictureBoxLogo.Image"), Image)
PictureBoxLogo.Location = New Point(12, 12)
PictureBoxLogo.Name = "PictureBoxLogo"
PictureBoxLogo.Size = New Size(99, 111)
PictureBoxLogo.SizeMode = PictureBoxSizeMode.StretchImage
PictureBoxLogo.TabIndex = 0
PictureBoxLogo.TabStop = False
'
' LabelProgramName
'
LabelProgramName.AutoSize = True
LabelProgramName.Font = New Font("Ink Free", 14.25F, FontStyle.Bold, GraphicsUnit.Point)
LabelProgramName.ForeColor = SystemColors.ControlText
LabelProgramName.Location = New Point(4, 11)
LabelProgramName.Name = "LabelProgramName"
LabelProgramName.Size = New Size(60, 23)
LabelProgramName.TabIndex = 3
LabelProgramName.Text = "Name"
'
' LabelProgramDescription
'
LabelProgramDescription.AutoSize = True
LabelProgramDescription.Font = New Font("Segoe UI Semibold", 9F, FontStyle.Bold, GraphicsUnit.Point)
LabelProgramDescription.ForeColor = SystemColors.ControlText
LabelProgramDescription.Location = New Point(4, 54)
LabelProgramDescription.Name = "LabelProgramDescription"
LabelProgramDescription.Size = New Size(68, 15)
LabelProgramDescription.TabIndex = 4
LabelProgramDescription.Text = "Description"
'
' LabelVersion
'
LabelVersion.AutoSize = True
LabelVersion.Font = New Font("Segoe UI", 9F, FontStyle.Underline, GraphicsUnit.Point)
LabelVersion.ForeColor = SystemColors.ControlText
LabelVersion.Location = New Point(372, 17)
LabelVersion.Name = "LabelVersion"
LabelVersion.Size = New Size(45, 15)
LabelVersion.TabIndex = 5
LabelVersion.Text = "Version"
'
' LinkLabelReadtheWiki
'
LinkLabelReadtheWiki.AutoSize = True
LinkLabelReadtheWiki.Font = New Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point)
LinkLabelReadtheWiki.Location = New Point(337, 54)
LinkLabelReadtheWiki.Name = "LinkLabelReadtheWiki"
LinkLabelReadtheWiki.Size = New Size(79, 15)
LinkLabelReadtheWiki.TabIndex = 6
LinkLabelReadtheWiki.TabStop = True
LinkLabelReadtheWiki.Text = "Read the Wiki"
'
' Panel1
'
Panel1.BackColor = SystemColors.Control
Panel1.Controls.Add(LabelProgramDescription)
Panel1.Controls.Add(LabelProgramName)
Panel1.Controls.Add(LinkLabelReadtheWiki)
Panel1.Controls.Add(LabelVersion)
Panel1.Location = New Point(117, 12)
Panel1.Name = "Panel1"
Panel1.Size = New Size(440, 111)
Panel1.TabIndex = 7
'
' LicenseRichTextBox
'
LicenseRichTextBox.Font = New Font("Segoe UI Semibold", 9F, FontStyle.Bold, GraphicsUnit.Point)
LicenseRichTextBox.Location = New Point(28, 170)
LicenseRichTextBox.Font = New Font("Cambria", 9.75F, FontStyle.Regular, GraphicsUnit.Point)
LicenseRichTextBox.Location = New Point(12, 135)
LicenseRichTextBox.Name = "LicenseRichTextBox"
LicenseRichTextBox.ReadOnly = True
LicenseRichTextBox.Size = New Size(513, 342)
LicenseRichTextBox.Size = New Size(545, 305)
LicenseRichTextBox.TabIndex = 1
LicenseRichTextBox.Text = "License notice"
'
' LicenseLabel
'
LicenseLabel.AutoSize = True
LicenseLabel.Font = New Font("Microsoft JhengHei UI", 9.75F, FontStyle.Regular, GraphicsUnit.Point)
LicenseLabel.Location = New Point(28, 150)
LicenseLabel.Name = "LicenseLabel"
LicenseLabel.Size = New Size(52, 17)
LicenseLabel.TabIndex = 2
LicenseLabel.Text = "License"
'
' ProgramNameLabel
'
ProgramNameLabel.AutoSize = True
ProgramNameLabel.Font = New Font("Microsoft JhengHei", 14.25F, FontStyle.Bold, GraphicsUnit.Point)
ProgramNameLabel.Location = New Point(126, 47)
ProgramNameLabel.Name = "ProgramNameLabel"
ProgramNameLabel.Size = New Size(66, 24)
ProgramNameLabel.TabIndex = 3
ProgramNameLabel.Text = "Name"
'
' DescriptionLabel
'
DescriptionLabel.AutoSize = True
DescriptionLabel.Font = New Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point)
DescriptionLabel.Location = New Point(126, 81)
DescriptionLabel.Name = "DescriptionLabel"
DescriptionLabel.Size = New Size(67, 15)
DescriptionLabel.TabIndex = 4
DescriptionLabel.Text = "Description"
'
' VersionLabel
'
VersionLabel.AutoSize = True
VersionLabel.Font = New Font("Segoe UI", 9F, FontStyle.Italic, GraphicsUnit.Point)
VersionLabel.Location = New Point(500, 54)
VersionLabel.Name = "VersionLabel"
VersionLabel.Size = New Size(46, 15)
VersionLabel.TabIndex = 5
VersionLabel.Text = "Version"
'
' WikiLinkLabel
'
WikiLinkLabel.AutoSize = True
WikiLinkLabel.Location = New Point(511, 81)
WikiLinkLabel.Name = "WikiLinkLabel"
WikiLinkLabel.Size = New Size(30, 15)
WikiLinkLabel.TabIndex = 6
WikiLinkLabel.TabStop = True
WikiLinkLabel.Text = "Wiki"
'
' AboutBox
'
AutoScaleDimensions = New SizeF(7F, 15F)
AutoScaleMode = AutoScaleMode.Font
BackColor = Color.Gainsboro
ClientSize = New Size(569, 541)
Controls.Add(WikiLinkLabel)
Controls.Add(VersionLabel)
Controls.Add(DescriptionLabel)
Controls.Add(ProgramNameLabel)
Controls.Add(LicenseLabel)
ClientSize = New Size(569, 454)
Controls.Add(LicenseRichTextBox)
Controls.Add(PictureBox1)
Controls.Add(Panel1)
Controls.Add(PictureBoxLogo)
FormBorderStyle = FormBorderStyle.FixedSingle
Icon = CType(resources.GetObject("$this.Icon"), Icon)
MaximizeBox = False
@@ -124,16 +128,17 @@ Partial Class AboutBox
ShowInTaskbar = False
StartPosition = FormStartPosition.CenterScreen
Text = "About"
CType(PictureBox1, ComponentModel.ISupportInitialize).EndInit()
CType(PictureBoxLogo, ComponentModel.ISupportInitialize).EndInit()
Panel1.ResumeLayout(False)
Panel1.PerformLayout()
ResumeLayout(False)
PerformLayout()
End Sub
Friend WithEvents PictureBox1 As PictureBox
Friend WithEvents PictureBoxLogo As PictureBox
Friend WithEvents LabelProgramName As Label
Friend WithEvents LabelProgramDescription As Label
Friend WithEvents LabelVersion As Label
Friend WithEvents LinkLabelReadtheWiki As LinkLabel
Friend WithEvents Panel1 As Panel
Friend WithEvents LicenseRichTextBox As RichTextBox
Friend WithEvents LicenseLabel As Label
Friend WithEvents ProgramNameLabel As Label
Friend WithEvents DescriptionLabel As Label
Friend WithEvents VersionLabel As Label
Friend WithEvents WikiLinkLabel As LinkLabel
End Class

View File

@@ -118,10 +118,10 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="PictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<data name="PictureBoxLogo.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAN
0wAADdMBvdUcagAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAFPuSURBVHhe7d0J
0AAADdABEGw9BwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAFPuSURBVHhe7d0J
nBxVvTZ+ExbZVPTPX0Svonjd5b0qV0UEARXR60Xvq2yyi4DsskR2QfZNEEE2gbAIAgEEAgQIS4BAQEh6
uqfXmUkySaYHbyCsCXuSep9fJyOdzjMz3dW1nKp++Hy+H+AH6e4659T5nao6dc57PM8TERGRDkODIiIi
km40KCIiIulGgyIiIpJuNCgiIiLpRoMiIiKSbjQoIiIi6UaDIiIikm40KCIiIulGgyIiIpJuNCgiIiLp

View File

@@ -1,7 +1,10 @@
Public Class AboutBox
Public Property LicenseText As String = "MIT License
Imports System.Runtime
Copyright (c) 2023-2024 Richard Mwewa
Public Class AboutBox
ReadOnly settings As New SettingsManager()
Public Property LicenseText As String = $"MIT License
{My.Application.Info.Copyright}
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the ""Software""), to deal
@@ -18,19 +21,33 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE."
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
Private Sub AboutForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ProgramNameLabel.Text = My.Application.Info.AssemblyName
DescriptionLabel.Text = "Given a subreddit name and a keyword,
''' <summary>
''' Handles the Load event for the AboutBox form.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">The event data.</param>
Private Sub AboutBox_Load(sender As Object, e As EventArgs) Handles MyBase.Load
settings.LoadSettings()
settings.ToggleDarkMode(settings.DarkMode)
LabelProgramName.Text = My.Application.Info.ProductName
LabelProgramDescription.Text = "Given a subreddit name and a keyword,
RPST returns all top posts
(by default) that contain the specified keyword."
VersionLabel.Text = $"v{My.Application.Info.Version}"
LabelVersion.Text = $"v{My.Application.Info.Version}"
LicenseRichTextBox.Text = LicenseText
End Sub
Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles WikiLinkLabel.LinkClicked
''' <summary>
''' Handles the LinkClicked event for the LinkLabelReadtheWiki control.
''' Opens the Wiki URL in the default browser.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">The event data.</param>
Private Sub LinkLabelReadtheWiki_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabelReadtheWiki.LinkClicked
Shell("cmd /c start https://github.com/bellingcat/reddit-post-scraping-tool/wiki")
End Sub
End Class
End Class

View File

@@ -7,31 +7,31 @@ Public Class DataGridViewHandler
''' <param name="dataGridView">The DataGridView to be initialized.</param>
Public Shared Sub AddColumn(dataGridView As DataGridView)
' Clear the Columns and Rows before adding Items to them
PostsForm.DataGridViewPosts.Rows.Clear()
PostsForm.DataGridViewPosts.Columns.Clear()
dataGridView.Rows.Clear()
dataGridView.Columns.Clear()
PostsForm.DataGridViewPosts.Columns.Add("PostCount", "Post Number")
PostsForm.DataGridViewPosts.Columns.Add("PostAuthor", "Author")
PostsForm.DataGridViewPosts.Columns.Add("PostID", "ID")
PostsForm.DataGridViewPosts.Columns.Add("PostSubreddit", "Subreddit")
PostsForm.DataGridViewPosts.Columns.Add("SubredditVisibility", "Subreddit Visibility")
PostsForm.DataGridViewPosts.Columns.Add("PostThumbnail", "Thumbnail")
PostsForm.DataGridViewPosts.Columns.Add("PostIsNSFW", "NSFW")
PostsForm.DataGridViewPosts.Columns.Add("PostIsGilded", "Gilded")
PostsForm.DataGridViewPosts.Columns.Add("PostUpvotes", "Upvotes")
PostsForm.DataGridViewPosts.Columns.Add("PostUpvoteRatio", "Upvote Ratio")
PostsForm.DataGridViewPosts.Columns.Add("PostDownvotes", "Downvotes")
PostsForm.DataGridViewPosts.Columns.Add("PostAwards", "Awards")
PostsForm.DataGridViewPosts.Columns.Add("PostTopAward", "Top Award")
PostsForm.DataGridViewPosts.Columns.Add("PostIsCrosspostable", "Is Crosspostable?")
PostsForm.DataGridViewPosts.Columns.Add("PostScore", "Score")
PostsForm.DataGridViewPosts.Columns.Add("PostText", "Text")
PostsForm.DataGridViewPosts.Columns.Add("PostCategory", "Category")
PostsForm.DataGridViewPosts.Columns.Add("PostDomain", "Domain")
PostsForm.DataGridViewPosts.Columns.Add("PostPermalink", "Permalink")
PostsForm.DataGridViewPosts.Columns.Add("PostCreatedAt", "Created At")
PostsForm.DataGridViewPosts.Columns.Add("PostApprovedAt", "Approved At")
PostsForm.DataGridViewPosts.Columns.Add("PostApprovedBy", "Approved By")
dataGridView.Columns.Add("PostCount", "Index")
dataGridView.Columns.Add("PostAuthor", "Author")
dataGridView.Columns.Add("PostID", "Post ID")
dataGridView.Columns.Add("PostText", "Post Text")
dataGridView.Columns.Add("PostSubreddit", "Subreddit")
dataGridView.Columns.Add("SubredditVisibility", "Subreddit Visibility")
dataGridView.Columns.Add("PostThumbnail", "Thumbnail")
dataGridView.Columns.Add("PostIsNSFW", "NSFW")
dataGridView.Columns.Add("PostIsGilded", "Gilded")
dataGridView.Columns.Add("PostUpvotes", "Upvotes")
dataGridView.Columns.Add("PostUpvoteRatio", "Upvote Ratio")
dataGridView.Columns.Add("PostDownvotes", "Downvotes")
dataGridView.Columns.Add("PostAwards", "Awards")
dataGridView.Columns.Add("PostTopAward", "Top Award")
dataGridView.Columns.Add("PostIsCrosspostable", "Is Crosspostable?")
dataGridView.Columns.Add("PostScore", "Score")
dataGridView.Columns.Add("PostCategory", "Category")
dataGridView.Columns.Add("PostDomain", "Domain")
dataGridView.Columns.Add("PostPermalink", "Permalink")
dataGridView.Columns.Add("PostCreatedAt", "Created At")
dataGridView.Columns.Add("PostApprovedAt", "Approved At")
dataGridView.Columns.Add("PostApprovedBy", "Approved By")
End Sub
Public Shared Sub AddRow(dataGridView As DataGridView, post As JObject, postNumber As Integer)
@@ -41,9 +41,10 @@ Public Class DataGridViewHandler
''' <param name="dataGridView">The DataGridView to which the row will be added.</param>
''' <param name="post">A JObject representing the Reddit post.</param>
''' <param name="postNumber">The number of the post.</param>
PostsForm.DataGridViewPosts.Rows.Add(postNumber,
dataGridView.Rows.Add(postNumber,
post("data")("author"),
post("data")("id"),
post("data")("selftext"),
post("data")("subreddit_name_prefixed"),
post("data")("subreddit_type"),
post("data")("thumbnail"),
@@ -56,7 +57,6 @@ Public Class DataGridViewHandler
post("data")("top_awarded_type"),
post("data")("is_crosspostable"),
post("data")("score"),
post("data")("selftext"),
post("data")("category"),
post("data")("domain"),
post("data")("permalink"),

View File

@@ -1,5 +1,5 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Partial Class DeveloperForm
Partial Class DeveloperBox
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
@@ -22,9 +22,9 @@ Partial Class DeveloperForm
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
Dim resources As ComponentModel.ComponentResourceManager = New ComponentModel.ComponentResourceManager(GetType(DeveloperForm))
Dim resources As ComponentModel.ComponentResourceManager = New ComponentModel.ComponentResourceManager(GetType(DeveloperBox))
AboutMeLinkLabel = New LinkLabel()
BuyMeACoffeeLinkLabel = New LinkLabel()
LinkLabelBuyMeACoffee = New LinkLabel()
GreetingLabel = New Label()
SuspendLayout()
'
@@ -32,37 +32,42 @@ Partial Class DeveloperForm
'
AboutMeLinkLabel.AutoSize = True
AboutMeLinkLabel.BackColor = Color.White
AboutMeLinkLabel.Font = New Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point)
AboutMeLinkLabel.Location = New Point(33, 426)
AboutMeLinkLabel.Name = "AboutMeLinkLabel"
AboutMeLinkLabel.Size = New Size(60, 15)
AboutMeLinkLabel.Size = New Size(57, 17)
AboutMeLinkLabel.TabIndex = 0
AboutMeLinkLabel.TabStop = True
AboutMeLinkLabel.Text = "About.me"'
' BuyMeACoffeeLinkLabel
AboutMeLinkLabel.Text = "About.me"
'
' LinkLabelBuyMeACoffee
'
LinkLabelBuyMeACoffee.AutoSize = True
LinkLabelBuyMeACoffee.Font = New Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point)
LinkLabelBuyMeACoffee.Location = New Point(33, 451)
LinkLabelBuyMeACoffee.Name = "LinkLabelBuyMeACoffee"
LinkLabelBuyMeACoffee.Size = New Size(101, 17)
LinkLabelBuyMeACoffee.TabIndex = 1
LinkLabelBuyMeACoffee.TabStop = True
LinkLabelBuyMeACoffee.Text = "Buy Me A Coffee"
'
BuyMeACoffeeLinkLabel.AutoSize = True
BuyMeACoffeeLinkLabel.Location = New Point(33, 451)
BuyMeACoffeeLinkLabel.Name = "BuyMeACoffeeLinkLabel"
BuyMeACoffeeLinkLabel.Size = New Size(96, 15)
BuyMeACoffeeLinkLabel.TabIndex = 1
BuyMeACoffeeLinkLabel.TabStop = True
BuyMeACoffeeLinkLabel.Text = "Buy Me A Coffee"'
' GreetingLabel
'
GreetingLabel.AutoSize = True
GreetingLabel.Font = New Font("Verdana", 27.75F, FontStyle.Bold, GraphicsUnit.Point)
GreetingLabel.Font = New Font("Ink Free", 27.75F, FontStyle.Bold, GraphicsUnit.Point)
GreetingLabel.Location = New Point(62, 22)
GreetingLabel.Name = "GreetingLabel"
GreetingLabel.Size = New Size(382, 45)
GreetingLabel.Size = New Size(355, 46)
GreetingLabel.TabIndex = 3
GreetingLabel.Text = "Hello, I'm Ritchie"'
GreetingLabel.Text = "👋🏾Hello, I'm Ritchie"
'
' DeveloperForm
'
AutoScaleDimensions = New SizeF(7F, 15F)
AutoScaleMode = AutoScaleMode.Font
BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), Image)
ClientSize = New Size(510, 510)
Controls.Add(BuyMeACoffeeLinkLabel)
Controls.Add(LinkLabelBuyMeACoffee)
Controls.Add(AboutMeLinkLabel)
Controls.Add(GreetingLabel)
FormBorderStyle = FormBorderStyle.FixedSingle
@@ -78,7 +83,7 @@ Partial Class DeveloperForm
End Sub
Friend WithEvents AboutMeLinkLabel As LinkLabel
Friend WithEvents BuyMeACoffeeLinkLabel As LinkLabel
Friend WithEvents LinkLabelBuyMeACoffee As LinkLabel
Friend WithEvents PictureBox1 As PictureBox
Friend WithEvents GreetingLabel As Label
End Class

View File

@@ -1,4 +1,64 @@
<root>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">

View File

@@ -1,8 +1,8 @@
Public Class DeveloperForm
Public Class DeveloperBox
Private Sub DeveloperForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
GreetingLabel.BackColor = Color.Transparent
AboutMeLinkLabel.BackColor = Color.Transparent
BuyMeACoffeeLinkLabel.BackColor = Color.Transparent
LinkLabelBuyMeACoffee.BackColor = Color.Transparent
End Sub
Private Sub AboutMeLinkLabel_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles AboutMeLinkLabel.LinkClicked
@@ -11,7 +11,7 @@
Shell("cmd /c start https://about.me/rly0nheart")
End Sub
Private Sub BuyMeACoffeeLinkLabel_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles BuyMeACoffeeLinkLabel.LinkClicked
Private Sub BuyMeACoffeeLinkLabel_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabelBuyMeACoffee.LinkClicked
Shell("cmd /c start https://buymeacoffee.com/_rly0nheart")
End Sub
End Class

View File

@@ -1,57 +0,0 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class PostsForm
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
DataGridViewPosts = New DataGridView()
CType(DataGridViewPosts, ComponentModel.ISupportInitialize).BeginInit()
SuspendLayout()
'
' DataGridViewPosts
'
DataGridViewPosts.BackgroundColor = Color.Gainsboro
DataGridViewPosts.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize
DataGridViewPosts.Dock = DockStyle.Fill
DataGridViewPosts.Location = New Point(0, 0)
DataGridViewPosts.Name = "DataGridViewPosts"
DataGridViewPosts.ReadOnly = True
DataGridViewPosts.RowHeadersVisible = False
DataGridViewPosts.RowTemplate.Height = 25
DataGridViewPosts.Size = New Size(800, 450)
DataGridViewPosts.TabIndex = 3
'
' PostsForm
'
AutoScaleDimensions = New SizeF(7F, 15F)
AutoScaleMode = AutoScaleMode.Font
ClientSize = New Size(800, 450)
Controls.Add(DataGridViewPosts)
Name = "PostsForm"
ShowIcon = False
ShowInTaskbar = False
Text = "PostsForm"
CType(DataGridViewPosts, ComponentModel.ISupportInitialize).EndInit()
ResumeLayout(False)
End Sub
Friend WithEvents DataGridViewPosts As DataGridView
End Class

View File

@@ -1,60 +0,0 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -1,3 +0,0 @@
Public Class PostsForm
End Class

View File

@@ -1,7 +1,7 @@
Imports Newtonsoft.Json.Linq
Public Class PostsProcessor
Private ApiHandler As New ApiHandler
Private ReadOnly ApiHandler As New ApiHandler
''' <summary>
''' Fetches Reddit posts based on the given parameters and returns them as a JObject.
@@ -23,7 +23,7 @@ Public Class PostsProcessor
''' <param name="keyword">The keyword to check for.</param>
''' <returns>True if the post contains the keyword, False otherwise.</returns>
Public Shared Function PostContainsKeyword(post As JObject, keyword As String) As Boolean
Return post("data")("selftext").ToString.ToLower(System.Globalization.CultureInfo.InvariantCulture).Contains(keyword.ToLower(System.Globalization.CultureInfo.InvariantCulture))
Return post("data")("selftext").ToString.ToLower(Globalization.CultureInfo.InvariantCulture).Contains(keyword.ToLower(System.Globalization.CultureInfo.InvariantCulture))
End Function
End Class

View File

@@ -1,29 +1,33 @@
# Reddit Post Scraping Tool
Given a subreddit name and a keyword, this script will return all posts from a specified listing (default is 'top') that contain the provided keyword.
# RPST (Reddit Post Scraping Tool)
Given a subreddit name and a keyword, RPST will return all posts from a specified listing (default is 'top') that contain the provided keyword.
[![Upload Python Package](https://github.com/rly0nheart/reddit-post-scraping-tool/actions/workflows/python-publish.yml/badge.svg)](https://github.com/rly0nheart/reddit-post-scraping-tool/actions/workflows/python-publish.yml) [![CodeQL](https://github.com/rly0nheart/reddit-post-scraping-tool/actions/workflows/codeql.yml/badge.svg)](https://github.com/rly0nheart/reddit-post-scraping-tool/actions/workflows/codeql.yml) ![.Net](https://img.shields.io/badge/.NET-5C2D91?style=flat&logo=.net&logoColor=white) ![Python](https://img.shields.io/badge/python-3670A0?style=flat&logo=python&logoColor=ffdd54)
![Screenshot 2023-02-10 195818](https://user-images.githubusercontent.com/74001397/218163494-245f6676-1fb3-4680-a6b5-bd15fb1dea5e.png)
![Screenshot_20230210_193329](https://user-images.githubusercontent.com/74001397/218158084-9295abb7-df33-4f86-8df8-e109cac7cde6.png)
![2023-08-08_07-04](https://github.com/bellingcat/reddit-post-scraping-tool/assets/74001397/10d91093-7b24-4de9-9f02-454b842d6b8e)
![2023-08-08_07-04_1](https://github.com/bellingcat/reddit-post-scraping-tool/assets/74001397/268a4c0e-d849-49a3-94ba-296d193774e1)
# Features (GUI)
- [x] Auto dark mode from 6pm - 6am
- [x] Saves results to a JSON
- [ ] Other features coming soon...
# Features
## GUI
- [x] Dark mode (Right-click)
- [x] Saves results to a JSON (Right-click)
- [x] Logs errors to a file
# TODO (GUI)
- [ ] Make it a stand alone executable
- [ ] Add manual dark mode option, that will be remembered in all sessions
## CLI
- [x] Saves results to a JSON (-j/--json)
- [x] Automatically checks for new updates. Notifies user if update were found.
# Wiki
# 📃 TODO
## GUI
- [ ] Make it installable with a setup.exe/setup.msi file.
- [x] Add manual dark mode option, that will be persistent in all sessions
- [ ] Make it save results to a CSV file
# 📖 Wiki
[Refer to the Wiki](https://github.com/rly0nheart/reddit-post-scraping-tool/wiki) for installation instructions, in addition to all other documentation.
# Note
> This is one of the projects I am working on, while learning Visual Basic, so the implementation/code may be messed up. If that's the case, please feel free to open a pull request using the available templates. Otherwise, enjoy!
# 😁 Donations
If you like `RPST` and would like to show support, you can Buy A Coffee for the developer using the button below
# Donations
If you like `Reddit Post Scraping Tool` and would like to show support, you can Buy A Coffee for the developer using the button below
<a href="https://www.buymeacoffee.com/189381184" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>
<a href="https://www.buymeacoffee.com/_rly0nheart" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>
Your support will be much appreciated😊

View File

@@ -13,19 +13,19 @@
<PackageProjectUrl>https://github.com/bellingcat/reddit-post-scraping-tool</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/bellingcat/reddit-post-scraping-tool</RepositoryUrl>
<AssemblyVersion>1.4.0.0</AssemblyVersion>
<FileVersion>1.4.0.0</FileVersion>
<AssemblyVersion>1.5.0.0</AssemblyVersion>
<FileVersion>1.5.0.0</FileVersion>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<Version>1.4.0</Version>
<Version>1.5.0</Version>
<PackageTags>reddit;scraper;reddit-scraper;osint</PackageTags>
<PackageReleaseNotes></PackageReleaseNotes>
<AnalysisLevel>6.0-recommended</AnalysisLevel>
<PackageId>RPST (Reddit Post Scraping Tool)</PackageId>
<PackageId>RPST</PackageId>
<Authors>Richard Mwewa</Authors>
<NeutralLanguage>en</NeutralLanguage>
<Product>$(AssemblyName)</Product>
<AssemblyName>RPST (Reddit Post Scraping Tool)</AssemblyName>
<Product>$(AssemblyName) (Reddit Post Scraping Tool)</Product>
<AssemblyName>RPST</AssemblyName>
</PropertyGroup>
<ItemGroup>

View File

@@ -4,10 +4,7 @@
<Compile Update="AboutBox.vb">
<SubType>Form</SubType>
</Compile>
<Compile Update="DeveloperForm.vb">
<SubType>Form</SubType>
</Compile>
<Compile Update="PostsForm.vb">
<Compile Update="DeveloperBox.vb">
<SubType>Form</SubType>
</Compile>
<Compile Update="StartForm.vb">

57
RPST GUI/RPST/ResultsForm.Designer.vb generated Normal file
View File

@@ -0,0 +1,57 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Partial Class ResultsForm
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()>
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
DataGridViewResults = New DataGridView()
CType(DataGridViewResults, ComponentModel.ISupportInitialize).BeginInit()
SuspendLayout()
'
' DataGridViewResults
'
DataGridViewResults.BackgroundColor = Color.Gainsboro
DataGridViewResults.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize
DataGridViewResults.Dock = DockStyle.Fill
DataGridViewResults.Location = New Point(0, 0)
DataGridViewResults.Name = "DataGridViewResults"
DataGridViewResults.ReadOnly = True
DataGridViewResults.RowHeadersVisible = False
DataGridViewResults.RowTemplate.Height = 25
DataGridViewResults.Size = New Size(800, 450)
DataGridViewResults.TabIndex = 3
'
' ResultsForm
'
AutoScaleDimensions = New SizeF(7.0F, 15.0F)
AutoScaleMode = AutoScaleMode.Font
ClientSize = New Size(800, 450)
Controls.Add(DataGridViewResults)
Name = "ResultsForm"
ShowIcon = False
ShowInTaskbar = False
Text = "ResultsForm"
CType(DataGridViewResults, ComponentModel.ISupportInitialize).EndInit()
ResumeLayout(False)
End Sub
Friend WithEvents DataGridViewResults As DataGridView
End Class

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1 @@


View File

@@ -1,16 +1,22 @@
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Imports System.IO
Imports System.Runtime
Imports System.IO
Imports System.Text.Json
Imports Newtonsoft.Json.Linq
Public Class SettingsManager
''' <summary>
''' Represents the Dark Mode property.
''' Indicates whether the dark mode is enabled or disabled.
''' </summary>
Public Property DarkMode As Boolean
Private ReadOnly settingsFilePath As String = Path.Combine(Environment.CurrentDirectory, "settings.json")
' Load settings from the 'settings.json' file
''' <summary>
''' Loads application settings from the 'settings.json' file.
''' If the settings file doesn't exist, it creates a new file with default settings.
''' </summary>
Public Sub LoadSettings()
' Check if the settings.json file exists
' and load the configurations from it
@@ -19,7 +25,7 @@ Public Class SettingsManager
Dim options As New JsonSerializerOptions With {.PropertyNameCaseInsensitive = True}
Dim settings = Text.Json.JsonSerializer.Deserialize(Of SettingsManager)(json, options)
Me.DarkMode = settings.DarkMode
StartForm.DarkModeToolStripMenuItem.Checked = settings.DarkMode
StartForm.ToolStripMenuItemDarkMode.Checked = settings.DarkMode
Else
' Settings file does not exist
' Create a new file with default settings 'False'
@@ -28,84 +34,176 @@ Public Class SettingsManager
File.WriteAllText(settingsFilePath, jsonOutput)
Me.DarkMode = False
StartForm.DarkModeToolStripMenuItem.Checked = False
StartForm.ToolStripMenuItemDarkMode.Checked = False
End If
End Sub
' Toggle Dark mode
''' <summary>
''' Toggles the Dark Mode setting on or off based on the provided parameter.
''' </summary>
''' <param name="enabled">A Boolean indicating if Dark Mode should be enabled or not.</param>
Public Sub ToggleDarkMode(enabled As Boolean)
Dim json As String = File.ReadAllText(settingsFilePath)
Dim options As New JsonSerializerOptions With {.PropertyNameCaseInsensitive = True}
Dim settings As SettingsManager = Text.Json.JsonSerializer.Deserialize(Of SettingsManager)(json, options)
Dim settings As SettingsManager = JsonSerializer.Deserialize(Of SettingsManager)(json, options)
settings.DarkMode = enabled
SaveSettings(settings)
ApplyTheme()
End Sub
' Save current settings to settings.json
''' <summary>
''' Saves the provided settings to the 'settings.json' file.
''' </summary>
''' <param name="settings">An instance of the SettingsManager containing the configurations to be saved.</param>
Private Sub SaveSettings(settings)
Dim jsonOutput = Text.Json.JsonSerializer.Serialize(settings)
Dim jsonOutput = JsonSerializer.Serialize(settings)
File.WriteAllText(settingsFilePath, jsonOutput)
End Sub
' Apply theme
''' <summary>
''' Applies the visual theme based on the Dark Mode setting.
''' If Dark Mode is enabled, a dark theme is applied. If it's disabled, a light theme is set.
''' </summary>
Public Sub ApplyTheme()
Dim DarkMode As Boolean = GetDarkMode()
If DarkMode Then
' Enable dark mode for the Main form
' Background colours (I know 'Colours'/'Colors'😆)
StartForm.BackColor = ColorTranslator.FromHtml("#FF121212")
StartForm.ToolsToolStripMenuTools.ForeColor = ColorTranslator.FromHtml("#FFFFFFFF")
StartForm.KeywordTextBox.BackColor = ColorTranslator.FromHtml("#FF2E2E2E")
StartForm.KeywordTextBox.ForeColor = ColorTranslator.FromHtml("#FFFFFFFF")
StartForm.SubredditTextBox.BackColor = ColorTranslator.FromHtml("#FF2E2E2E")
StartForm.SubredditTextBox.ForeColor = ColorTranslator.FromHtml("#FFFFFFFF")
StartForm.KeywordTextBox.BackColor = ColorTranslator.FromHtml("#FF2E2E2E")
StartForm.LimitNumericUpDown.BackColor = ColorTranslator.FromHtml("#FF2E2E2E")
StartForm.LimitNumericUpDown.ForeColor = ColorTranslator.FromHtml("#FFFFFFFF")
StartForm.LimitNumericUpDown.BackColor = ColorTranslator.FromHtml("#FF2E2E2E")
StartForm.LimitNumericUpDown.ForeColor = ColorTranslator.FromHtml("#FFFFFFFF")
StartForm.ListingComboBox.BackColor = ColorTranslator.FromHtml("#FF2E2E2E")
StartForm.ListingComboBox.ForeColor = ColorTranslator.FromHtml("#FFFFFFFF")
StartForm.TimeframeComboBox.BackColor = ColorTranslator.FromHtml("#FF2E2E2E")
StartForm.TimeframeComboBox.ForeColor = ColorTranslator.FromHtml("#FFFFFFFF")
StartForm.Label1.ForeColor = ColorTranslator.FromHtml("#FFFFFFFF")
StartForm.Label2.ForeColor = ColorTranslator.FromHtml("#FFFFFFFF")
StartForm.Label3.ForeColor = ColorTranslator.FromHtml("#FFFFFFFF")
StartForm.Label4.ForeColor = ColorTranslator.FromHtml("#FFFFFFFF")
StartForm.Label5.ForeColor = ColorTranslator.FromHtml("#FFFFFFFF")
' Foreground colours
StartForm.KeywordTextBox.ForeColor = SystemColors.Control
StartForm.SubredditTextBox.ForeColor = SystemColors.Control
StartForm.LimitNumericUpDown.ForeColor = SystemColors.Control
StartForm.LimitNumericUpDown.ForeColor = SystemColors.Control
StartForm.ListingComboBox.ForeColor = SystemColors.Control
StartForm.TimeframeComboBox.ForeColor = SystemColors.Control
StartForm.LabelRPST.ForeColor = SystemColors.Control
StartForm.LabelKeyword.ForeColor = SystemColors.Control
StartForm.LabelSubreddit.ForeColor = SystemColors.Control
StartForm.LabelLimit.ForeColor = SystemColors.Control
StartForm.LabelListing.ForeColor = SystemColors.Control
StartForm.LabelTimeframe.ForeColor = SystemColors.Control
ResultsForm.BackColor = ColorTranslator.FromHtml("#FF121212")
' Enable dark mode on 'Right Click Menu' items
' Background colours
StartForm.ToolStripMenuItemDarkMode.BackColor = ColorTranslator.FromHtml("#FF121212")
StartForm.ToolStripMenuItemSavePosts.BackColor = ColorTranslator.FromHtml("#FF121212")
StartForm.ToolStripMenuItemtoJSON.BackColor = ColorTranslator.FromHtml("#FF121212")
StartForm.ToolStripMenuItemtoCSV.BackColor = ColorTranslator.FromHtml("#FF121212")
StartForm.ToolStripMenuItemAbout.BackColor = ColorTranslator.FromHtml("#FF121212")
StartForm.ToolStripMenuItemDeveloper.BackColor = ColorTranslator.FromHtml("#FF121212")
StartForm.ToolStripMenuItemCheckUpdates.BackColor = ColorTranslator.FromHtml("#FF121212")
StartForm.ToolStripMenuItemQuit.BackColor = ColorTranslator.FromHtml("#FF121212")
' Foreground colours
StartForm.ToolStripMenuItemDarkMode.ForeColor = SystemColors.Control
StartForm.ToolStripMenuItemSavePosts.ForeColor = SystemColors.Control
StartForm.ToolStripMenuItemtoJSON.ForeColor = SystemColors.Control
StartForm.ToolStripMenuItemtoCSV.ForeColor = SystemColors.Control
StartForm.ToolStripMenuItemAbout.ForeColor = SystemColors.Control
StartForm.ToolStripMenuItemDeveloper.ForeColor = SystemColors.Control
StartForm.ToolStripMenuItemCheckUpdates.ForeColor = SystemColors.Control
StartForm.ToolStripMenuItemQuit.ForeColor = SystemColors.Control
' Enable dark mode for the About box
' Background colours
AboutBox.BackColor = ColorTranslator.FromHtml("#FF121212")
AboutBox.LicenseRichTextBox.BackColor = ColorTranslator.FromHtml("#FF2E2E2E")
AboutBox.Panel1.BackColor = ColorTranslator.FromHtml("#FF121212")
' Foreground colours
AboutBox.ForeColor = SystemColors.Control
AboutBox.LicenseRichTextBox.ForeColor = SystemColors.Control
AboutBox.LabelProgramName.ForeColor = SystemColors.Control
AboutBox.LabelProgramDescription.ForeColor = SystemColors.Control
AboutBox.LabelVersion.ForeColor = SystemColors.Control
' If dark mode is enabled, set the 'Dark Mode' text value to 'Light mode'
StartForm.ToolStripMenuItemDarkMode.Text = "Light Mode"
Else
StartForm.BackColor = ColorTranslator.FromHtml("#FFFFFFFF")
StartForm.ToolsToolStripMenuTools.ForeColor = ColorTranslator.FromHtml("#FF121212")
StartForm.KeywordTextBox.BackColor = ColorTranslator.FromHtml("#FFFFFFFF")
' Disable dark mode for the Main Form
' Background colours
StartForm.BackColor = Color.Gainsboro
StartForm.KeywordTextBox.BackColor = SystemColors.Control
StartForm.SubredditTextBox.BackColor = SystemColors.Control
StartForm.LimitNumericUpDown.BackColor = SystemColors.Control
StartForm.LimitNumericUpDown.BackColor = SystemColors.Control
StartForm.TimeframeComboBox.BackColor = SystemColors.Control
StartForm.ListingComboBox.BackColor = SystemColors.Control
' Foreground colours
StartForm.KeywordTextBox.ForeColor = ColorTranslator.FromHtml("#FF121212")
StartForm.SubredditTextBox.BackColor = ColorTranslator.FromHtml("#FFFFFFFF")
StartForm.SubredditTextBox.ForeColor = ColorTranslator.FromHtml("#FF121212")
StartForm.LimitNumericUpDown.BackColor = ColorTranslator.FromHtml("#FFFFFFFF")
StartForm.LimitNumericUpDown.ForeColor = ColorTranslator.FromHtml("#FF121212")
StartForm.LimitNumericUpDown.BackColor = ColorTranslator.FromHtml("#FFFFFFFF")
StartForm.LimitNumericUpDown.ForeColor = ColorTranslator.FromHtml("#FF121212")
StartForm.ListingComboBox.BackColor = ColorTranslator.FromHtml("#FFFFFFFF")
StartForm.ListingComboBox.ForeColor = ColorTranslator.FromHtml("#FF121212")
StartForm.TimeframeComboBox.BackColor = ColorTranslator.FromHtml("#FFFFFFFF")
StartForm.TimeframeComboBox.ForeColor = ColorTranslator.FromHtml("#FF121212")
StartForm.Label1.ForeColor = ColorTranslator.FromHtml("#FF121212")
StartForm.Label2.ForeColor = ColorTranslator.FromHtml("#FF121212")
StartForm.Label3.ForeColor = ColorTranslator.FromHtml("#FF121212")
StartForm.Label4.ForeColor = ColorTranslator.FromHtml("#FF121212")
StartForm.Label5.ForeColor = ColorTranslator.FromHtml("#FF121212")
StartForm.LabelRPST.ForeColor = ColorTranslator.FromHtml("#FF121212")
StartForm.LabelKeyword.ForeColor = ColorTranslator.FromHtml("#FF121212")
StartForm.LabelSubreddit.ForeColor = ColorTranslator.FromHtml("#FF121212")
StartForm.LabelLimit.ForeColor = ColorTranslator.FromHtml("#FF121212")
StartForm.LabelListing.ForeColor = ColorTranslator.FromHtml("#FF121212")
StartForm.LabelTimeframe.ForeColor = ColorTranslator.FromHtml("#FF121212")
' Disable dark mode on 'Right Click Menu' items
' Background colours
StartForm.ToolStripMenuItemDarkMode.BackColor = Color.Gainsboro
StartForm.ToolStripMenuItemSavePosts.BackColor = Color.Gainsboro
StartForm.ToolStripMenuItemtoJSON.BackColor = Color.Gainsboro
StartForm.ToolStripMenuItemtoCSV.BackColor = Color.Gainsboro
StartForm.ToolStripMenuItemAbout.BackColor = Color.Gainsboro
StartForm.ToolStripMenuItemDeveloper.BackColor = Color.Gainsboro
StartForm.ToolStripMenuItemCheckUpdates.BackColor = Color.Gainsboro
StartForm.ToolStripMenuItemQuit.BackColor = Color.Gainsboro
' Foreground colours
StartForm.ToolStripMenuItemDarkMode.ForeColor = Color.Black
StartForm.ToolStripMenuItemSavePosts.ForeColor = Color.Black
StartForm.ToolStripMenuItemtoJSON.ForeColor = Color.Black
StartForm.ToolStripMenuItemtoCSV.ForeColor = Color.Black
StartForm.ToolStripMenuItemAbout.ForeColor = Color.Black
StartForm.ToolStripMenuItemDeveloper.ForeColor = Color.Black
StartForm.ToolStripMenuItemCheckUpdates.ForeColor = Color.Black
StartForm.ToolStripMenuItemQuit.ForeColor = Color.Black
' Disable dark mode for the About box
' Background colours
AboutBox.BackColor = Color.Gainsboro
AboutBox.ForeColor = SystemColors.WindowText
AboutBox.LicenseRichTextBox.BackColor = SystemColors.Control
AboutBox.LicenseRichTextBox.ForeColor = SystemColors.WindowText
AboutBox.Panel1.BackColor = Color.Gainsboro
' Foreground colours
AboutBox.Panel1.ForeColor = SystemColors.WindowText
AboutBox.LabelProgramName.ForeColor = SystemColors.WindowText
AboutBox.LabelProgramDescription.ForeColor = SystemColors.WindowText
AboutBox.LabelVersion.ForeColor = SystemColors.WindowText
' If dark mode is disabled, set the 'Light Mode' text value to 'Dark Mode'
StartForm.ToolStripMenuItemDarkMode.Text = "Dark Mode"
End If
End Sub
' Get dark mode state from settings.json's key 'DarkMode'
''' <summary>
''' Retrieves the Dark Mode setting value from 'settings.json'.
''' If the settings file doesn't exist, defaults to returning 'False' (Dark Mode off).
''' </summary>
''' <returns>A Boolean indicating if Dark Mode is enabled or not.</returns>
Private Function GetDarkMode() As Boolean
If File.Exists(settingsFilePath) Then
Dim json As String = File.ReadAllText(settingsFilePath)
Dim settings As JObject = JObject.Parse(json)
Return settings("DarkMode").ToObject(Of Boolean)()
Return settings(NameOf(DarkMode)).ToObject(Of Boolean)()
Else
Return False
End If
End Function
End Class

View File

@@ -26,38 +26,36 @@ Partial Class StartForm
Dim resources As ComponentModel.ComponentResourceManager = New ComponentModel.ComponentResourceManager(GetType(StartForm))
KeywordTextBox = New TextBox()
SubredditTextBox = New TextBox()
ScrapeButton = New Button()
ButtonScrape = New Button()
TimeframeComboBox = New ComboBox()
ListingComboBox = New ComboBox()
Label1 = New Label()
Label2 = New Label()
Label3 = New Label()
Label4 = New Label()
Label5 = New Label()
ContextMenuStrip1 = New ContextMenuStrip(components)
SaveResultsStripMenuItem = New ToolStripMenuItem()
JSONToolStripMenuItem = New ToolStripMenuItem()
CSVToolStripMenuItem = New ToolStripMenuItem()
DarkModeToolStripMenuItem = New ToolStripMenuItem()
FileMenuStrip = New MenuStrip()
ToolsToolStripMenuTools = New ToolStripMenuItem()
AboutToolStripMenuItem = New ToolStripMenuItem()
DeveloperToolStripMenuItem = New ToolStripMenuItem()
CheckUpdatesToolStripMenuItem = New ToolStripMenuItem()
ToolStripSeparator2 = New ToolStripSeparator()
QuitToolStripMenuItem = New ToolStripMenuItem()
LabelKeyword = New Label()
LabelSubreddit = New Label()
LabelLimit = New Label()
LabelListing = New Label()
LabelTimeframe = New Label()
ContextMenuStripRightClick = New ContextMenuStrip(components)
ToolStripMenuItemDarkMode = New ToolStripMenuItem()
ToolStripMenuItemSavePosts = New ToolStripMenuItem()
ToolStripMenuItemtoJSON = New ToolStripMenuItem()
ToolStripMenuItemtoCSV = New ToolStripMenuItem()
ToolStripMenuItemAbout = New ToolStripMenuItem()
ToolStripMenuItemDeveloper = New ToolStripMenuItem()
ToolStripMenuItemCheckUpdates = New ToolStripMenuItem()
ToolStripMenuItemQuit = New ToolStripMenuItem()
LimitNumericUpDown = New NumericUpDown()
ToolTip1 = New ToolTip(components)
ContextMenuStrip1.SuspendLayout()
FileMenuStrip.SuspendLayout()
PictureBoxLogo = New PictureBox()
LabelRPST = New Label()
ContextMenuStripRightClick.SuspendLayout()
CType(LimitNumericUpDown, ComponentModel.ISupportInitialize).BeginInit()
CType(PictureBoxLogo, ComponentModel.ISupportInitialize).BeginInit()
SuspendLayout()
'
' KeywordTextBox
'
KeywordTextBox.BackColor = SystemColors.Window
KeywordTextBox.ForeColor = SystemColors.WindowText
KeywordTextBox.Location = New Point(89, 60)
KeywordTextBox.Location = New Point(159, 75)
KeywordTextBox.Name = "KeywordTextBox"
KeywordTextBox.PlaceholderText = "Keyword"
KeywordTextBox.Size = New Size(100, 23)
@@ -65,26 +63,26 @@ Partial Class StartForm
'
' SubredditTextBox
'
SubredditTextBox.Location = New Point(89, 92)
SubredditTextBox.Location = New Point(159, 106)
SubredditTextBox.Name = "SubredditTextBox"
SubredditTextBox.PlaceholderText = "Subreddit"
SubredditTextBox.Size = New Size(100, 23)
SubredditTextBox.TabIndex = 4
'
' ScrapeButton
' ButtonScrape
'
ScrapeButton.Location = New Point(257, 191)
ScrapeButton.Name = "ScrapeButton"
ScrapeButton.Size = New Size(76, 28)
ScrapeButton.TabIndex = 6
ScrapeButton.Text = "Scrape"
ScrapeButton.UseVisualStyleBackColor = True
ButtonScrape.Location = New Point(208, 29)
ButtonScrape.Name = "ButtonScrape"
ButtonScrape.Size = New Size(51, 28)
ButtonScrape.TabIndex = 6
ButtonScrape.Text = "Scrape"
ButtonScrape.UseVisualStyleBackColor = True
'
' TimeframeComboBox
'
TimeframeComboBox.FormattingEnabled = True
TimeframeComboBox.Items.AddRange(New Object() {"Hour", "Day", "Week", "Month", "Year"})
TimeframeComboBox.Location = New Point(89, 191)
TimeframeComboBox.Location = New Point(159, 200)
TimeframeComboBox.Name = "TimeframeComboBox"
TimeframeComboBox.Size = New Size(100, 23)
TimeframeComboBox.TabIndex = 8
@@ -94,168 +92,145 @@ Partial Class StartForm
'
ListingComboBox.FormattingEnabled = True
ListingComboBox.Items.AddRange(New Object() {"Controversial", "Hot", "Best", "New", "Rising"})
ListingComboBox.Location = New Point(89, 157)
ListingComboBox.Location = New Point(159, 168)
ListingComboBox.Name = "ListingComboBox"
ListingComboBox.Size = New Size(100, 23)
ListingComboBox.TabIndex = 9
ListingComboBox.Text = "Top"
'
' Label1
' LabelKeyword
'
Label1.AutoEllipsis = True
Label1.Font = New Font("Segoe UI Semibold", 9F, FontStyle.Underline, GraphicsUnit.Point)
Label1.ForeColor = Color.Black
Label1.Location = New Point(12, 60)
Label1.Name = "Label1"
Label1.Size = New Size(56, 23)
Label1.TabIndex = 10
Label1.Text = "Keyword"
LabelKeyword.AutoEllipsis = True
LabelKeyword.Font = New Font("Segoe UI Semibold", 9F, FontStyle.Bold Or FontStyle.Underline, GraphicsUnit.Point)
LabelKeyword.ForeColor = Color.Black
LabelKeyword.Location = New Point(19, 78)
LabelKeyword.Name = "LabelKeyword"
LabelKeyword.Size = New Size(71, 20)
LabelKeyword.TabIndex = 10
LabelKeyword.Text = "Keyword:"
'
' Label2
' LabelSubreddit
'
Label2.AutoEllipsis = True
Label2.Font = New Font("Segoe UI Semibold", 9F, FontStyle.Underline, GraphicsUnit.Point)
Label2.ForeColor = Color.Black
Label2.Location = New Point(12, 92)
Label2.Name = "Label2"
Label2.Size = New Size(63, 23)
Label2.TabIndex = 11
Label2.Text = "Subreddit"
LabelSubreddit.AutoEllipsis = True
LabelSubreddit.Font = New Font("Segoe UI Semibold", 9F, FontStyle.Bold Or FontStyle.Underline, GraphicsUnit.Point)
LabelSubreddit.ForeColor = Color.Black
LabelSubreddit.Location = New Point(19, 109)
LabelSubreddit.Name = "LabelSubreddit"
LabelSubreddit.Size = New Size(71, 23)
LabelSubreddit.TabIndex = 11
LabelSubreddit.Text = "Subreddit:"
'
' Label3
' LabelLimit
'
Label3.AutoEllipsis = True
Label3.Font = New Font("Segoe UI Semibold", 9F, FontStyle.Bold Or FontStyle.Underline, GraphicsUnit.Point)
Label3.ForeColor = Color.Black
Label3.Location = New Point(12, 125)
Label3.Name = "Label3"
Label3.Size = New Size(56, 23)
Label3.TabIndex = 12
Label3.Text = "Limit"
LabelLimit.AutoEllipsis = True
LabelLimit.Font = New Font("Segoe UI Semibold", 9F, FontStyle.Bold Or FontStyle.Underline, GraphicsUnit.Point)
LabelLimit.ForeColor = Color.Black
LabelLimit.Location = New Point(19, 137)
LabelLimit.Name = "LabelLimit"
LabelLimit.Size = New Size(56, 23)
LabelLimit.TabIndex = 12
LabelLimit.Text = "Limit:"
'
' Label4
' LabelListing
'
Label4.AutoEllipsis = True
Label4.Font = New Font("Segoe UI Semibold", 9F, FontStyle.Bold Or FontStyle.Underline, GraphicsUnit.Point)
Label4.ForeColor = Color.Black
Label4.Location = New Point(12, 157)
Label4.Name = "Label4"
Label4.Size = New Size(56, 23)
Label4.TabIndex = 13
Label4.Text = "Listing"
LabelListing.AutoEllipsis = True
LabelListing.Font = New Font("Segoe UI Semibold", 9F, FontStyle.Bold Or FontStyle.Underline, GraphicsUnit.Point)
LabelListing.ForeColor = Color.Black
LabelListing.Location = New Point(19, 168)
LabelListing.Name = "LabelListing"
LabelListing.Size = New Size(56, 23)
LabelListing.TabIndex = 13
LabelListing.Text = "Listing:"
'
' Label5
' LabelTimeframe
'
Label5.AutoEllipsis = True
Label5.Font = New Font("Segoe UI Semibold", 9F, FontStyle.Bold Or FontStyle.Underline, GraphicsUnit.Point)
Label5.ForeColor = Color.Black
Label5.Location = New Point(12, 191)
Label5.Name = "Label5"
Label5.Size = New Size(71, 23)
Label5.TabIndex = 14
Label5.Text = "Timeframe"
LabelTimeframe.AutoEllipsis = True
LabelTimeframe.Font = New Font("Segoe UI Semibold", 9F, FontStyle.Bold Or FontStyle.Underline, GraphicsUnit.Point)
LabelTimeframe.ForeColor = Color.Black
LabelTimeframe.Location = New Point(19, 200)
LabelTimeframe.Name = "LabelTimeframe"
LabelTimeframe.Size = New Size(81, 23)
LabelTimeframe.TabIndex = 14
LabelTimeframe.Text = "Timeframe:"
'
' ContextMenuStrip1
' ContextMenuStripRightClick
'
ContextMenuStrip1.Items.AddRange(New ToolStripItem() {SaveResultsStripMenuItem, DarkModeToolStripMenuItem})
ContextMenuStrip1.Name = "ContextMenuStrip1"
ContextMenuStrip1.Size = New Size(144, 48)
ContextMenuStripRightClick.Items.AddRange(New ToolStripItem() {ToolStripMenuItemDarkMode, ToolStripMenuItemSavePosts, ToolStripMenuItemAbout, ToolStripMenuItemDeveloper, ToolStripMenuItemCheckUpdates, ToolStripMenuItemQuit})
ContextMenuStripRightClick.Name = "ContextMenuStrip1"
ContextMenuStripRightClick.Size = New Size(154, 136)
'
' SaveResultsStripMenuItem
' ToolStripMenuItemDarkMode
'
SaveResultsStripMenuItem.AutoToolTip = True
SaveResultsStripMenuItem.DropDownItems.AddRange(New ToolStripItem() {JSONToolStripMenuItem, CSVToolStripMenuItem})
SaveResultsStripMenuItem.Image = CType(resources.GetObject("SaveResultsStripMenuItem.Image"), Image)
SaveResultsStripMenuItem.Name = "SaveResultsStripMenuItem"
SaveResultsStripMenuItem.Size = New Size(143, 22)
SaveResultsStripMenuItem.Text = "Save posts to"
ToolStripMenuItemDarkMode.AutoToolTip = True
ToolStripMenuItemDarkMode.CheckOnClick = True
ToolStripMenuItemDarkMode.Image = CType(resources.GetObject("ToolStripMenuItemDarkMode.Image"), Image)
ToolStripMenuItemDarkMode.Name = "ToolStripMenuItemDarkMode"
ToolStripMenuItemDarkMode.Size = New Size(153, 22)
ToolStripMenuItemDarkMode.Text = "Dark Mode"
'
' JSONToolStripMenuItem
' ToolStripMenuItemSavePosts
'
JSONToolStripMenuItem.AutoToolTip = True
JSONToolStripMenuItem.CheckOnClick = True
JSONToolStripMenuItem.Image = CType(resources.GetObject("JSONToolStripMenuItem.Image"), Image)
JSONToolStripMenuItem.Name = "JSONToolStripMenuItem"
JSONToolStripMenuItem.Size = New Size(185, 22)
JSONToolStripMenuItem.Text = "JSON"
ToolStripMenuItemSavePosts.AutoToolTip = True
ToolStripMenuItemSavePosts.DropDownItems.AddRange(New ToolStripItem() {ToolStripMenuItemtoJSON, ToolStripMenuItemtoCSV})
ToolStripMenuItemSavePosts.Image = CType(resources.GetObject("ToolStripMenuItemSavePosts.Image"), Image)
ToolStripMenuItemSavePosts.Name = "ToolStripMenuItemSavePosts"
ToolStripMenuItemSavePosts.Size = New Size(153, 22)
ToolStripMenuItemSavePosts.Text = "Save Posts"
ToolStripMenuItemSavePosts.ToolTipText = "Save found posts to..."
'
' CSVToolStripMenuItem
' ToolStripMenuItemtoJSON
'
CSVToolStripMenuItem.AutoToolTip = True
CSVToolStripMenuItem.Enabled = False
CSVToolStripMenuItem.Image = CType(resources.GetObject("CSVToolStripMenuItem.Image"), Image)
CSVToolStripMenuItem.Name = "CSVToolStripMenuItem"
CSVToolStripMenuItem.Size = New Size(185, 22)
CSVToolStripMenuItem.Text = "CSV (coming soon...)"
ToolStripMenuItemtoJSON.AutoToolTip = True
ToolStripMenuItemtoJSON.CheckOnClick = True
ToolStripMenuItemtoJSON.Image = CType(resources.GetObject("ToolStripMenuItemtoJSON.Image"), Image)
ToolStripMenuItemtoJSON.Name = "ToolStripMenuItemtoJSON"
ToolStripMenuItemtoJSON.Size = New Size(116, 22)
ToolStripMenuItemtoJSON.Text = "to JSON"
'
' DarkModeToolStripMenuItem
' ToolStripMenuItemtoCSV
'
DarkModeToolStripMenuItem.AutoToolTip = True
DarkModeToolStripMenuItem.CheckOnClick = True
DarkModeToolStripMenuItem.Image = CType(resources.GetObject("DarkModeToolStripMenuItem.Image"), Image)
DarkModeToolStripMenuItem.Name = "DarkModeToolStripMenuItem"
DarkModeToolStripMenuItem.Size = New Size(143, 22)
DarkModeToolStripMenuItem.Text = "Dark mode"
ToolStripMenuItemtoCSV.AutoToolTip = True
ToolStripMenuItemtoCSV.Enabled = False
ToolStripMenuItemtoCSV.Image = CType(resources.GetObject("ToolStripMenuItemtoCSV.Image"), Image)
ToolStripMenuItemtoCSV.Name = "ToolStripMenuItemtoCSV"
ToolStripMenuItemtoCSV.Size = New Size(116, 22)
ToolStripMenuItemtoCSV.Text = "to CSV"
'
' FileMenuStrip
' ToolStripMenuItemAbout
'
FileMenuStrip.BackColor = Color.Transparent
FileMenuStrip.Items.AddRange(New ToolStripItem() {ToolsToolStripMenuTools})
FileMenuStrip.Location = New Point(0, 0)
FileMenuStrip.Name = "FileMenuStrip"
FileMenuStrip.Size = New Size(355, 24)
FileMenuStrip.TabIndex = 0
FileMenuStrip.Text = "MenuStrip1"
ToolStripMenuItemAbout.AutoToolTip = True
ToolStripMenuItemAbout.Image = CType(resources.GetObject("ToolStripMenuItemAbout.Image"), Image)
ToolStripMenuItemAbout.Name = "ToolStripMenuItemAbout"
ToolStripMenuItemAbout.Size = New Size(153, 22)
ToolStripMenuItemAbout.Text = "About"
'
' ToolsToolStripMenuTools
' ToolStripMenuItemDeveloper
'
ToolsToolStripMenuTools.DropDownItems.AddRange(New ToolStripItem() {AboutToolStripMenuItem, DeveloperToolStripMenuItem, CheckUpdatesToolStripMenuItem, ToolStripSeparator2, QuitToolStripMenuItem})
ToolsToolStripMenuTools.Font = New Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point)
ToolsToolStripMenuTools.ForeColor = Color.White
ToolsToolStripMenuTools.Image = CType(resources.GetObject("ToolsToolStripMenuTools.Image"), Image)
ToolsToolStripMenuTools.Name = "ToolsToolStripMenuTools"
ToolsToolStripMenuTools.Size = New Size(28, 20)
ToolStripMenuItemDeveloper.AutoToolTip = True
ToolStripMenuItemDeveloper.Image = CType(resources.GetObject("ToolStripMenuItemDeveloper.Image"), Image)
ToolStripMenuItemDeveloper.Name = "ToolStripMenuItemDeveloper"
ToolStripMenuItemDeveloper.Size = New Size(153, 22)
ToolStripMenuItemDeveloper.Text = "Developer"
'
' AboutToolStripMenuItem
' ToolStripMenuItemCheckUpdates
'
AboutToolStripMenuItem.AutoToolTip = True
AboutToolStripMenuItem.Image = CType(resources.GetObject("AboutToolStripMenuItem.Image"), Image)
AboutToolStripMenuItem.Name = "AboutToolStripMenuItem"
AboutToolStripMenuItem.Size = New Size(180, 22)
AboutToolStripMenuItem.Text = "About"
ToolStripMenuItemCheckUpdates.AutoToolTip = True
ToolStripMenuItemCheckUpdates.Image = CType(resources.GetObject("ToolStripMenuItemCheckUpdates.Image"), Image)
ToolStripMenuItemCheckUpdates.Name = "ToolStripMenuItemCheckUpdates"
ToolStripMenuItemCheckUpdates.Size = New Size(153, 22)
ToolStripMenuItemCheckUpdates.Text = "Check Updates"
'
' DeveloperToolStripMenuItem
' ToolStripMenuItemQuit
'
DeveloperToolStripMenuItem.AutoToolTip = True
DeveloperToolStripMenuItem.Image = CType(resources.GetObject("DeveloperToolStripMenuItem.Image"), Image)
DeveloperToolStripMenuItem.Name = "DeveloperToolStripMenuItem"
DeveloperToolStripMenuItem.Size = New Size(180, 22)
DeveloperToolStripMenuItem.Text = "Developer"
'
' CheckUpdatesToolStripMenuItem
'
CheckUpdatesToolStripMenuItem.AutoToolTip = True
CheckUpdatesToolStripMenuItem.Image = CType(resources.GetObject("CheckUpdatesToolStripMenuItem.Image"), Image)
CheckUpdatesToolStripMenuItem.Name = "CheckUpdatesToolStripMenuItem"
CheckUpdatesToolStripMenuItem.Size = New Size(180, 22)
CheckUpdatesToolStripMenuItem.Text = "Check updates"
'
' ToolStripSeparator2
'
ToolStripSeparator2.Name = "ToolStripSeparator2"
ToolStripSeparator2.Size = New Size(177, 6)
'
' QuitToolStripMenuItem
'
QuitToolStripMenuItem.AutoToolTip = True
QuitToolStripMenuItem.Image = CType(resources.GetObject("QuitToolStripMenuItem.Image"), Image)
QuitToolStripMenuItem.Name = "QuitToolStripMenuItem"
QuitToolStripMenuItem.Size = New Size(180, 22)
QuitToolStripMenuItem.Text = "Quit"
ToolStripMenuItemQuit.AutoToolTip = True
ToolStripMenuItemQuit.Image = CType(resources.GetObject("ToolStripMenuItemQuit.Image"), Image)
ToolStripMenuItemQuit.Name = "ToolStripMenuItemQuit"
ToolStripMenuItemQuit.Size = New Size(153, 22)
ToolStripMenuItemQuit.Text = "Quit"
'
' LimitNumericUpDown
'
LimitNumericUpDown.Location = New Point(89, 125)
LimitNumericUpDown.Location = New Point(159, 137)
LimitNumericUpDown.Minimum = New Decimal(New Integer() {5, 0, 0, 0})
LimitNumericUpDown.Name = "LimitNumericUpDown"
LimitNumericUpDown.ReadOnly = True
@@ -263,62 +238,81 @@ Partial Class StartForm
LimitNumericUpDown.TabIndex = 15
LimitNumericUpDown.Value = New Decimal(New Integer() {10, 0, 0, 0})
'
' PictureBoxLogo
'
PictureBoxLogo.BackColor = Color.Transparent
PictureBoxLogo.Image = CType(resources.GetObject("PictureBoxLogo.Image"), Image)
PictureBoxLogo.Location = New Point(19, 12)
PictureBoxLogo.Name = "PictureBoxLogo"
PictureBoxLogo.Size = New Size(41, 45)
PictureBoxLogo.SizeMode = PictureBoxSizeMode.StretchImage
PictureBoxLogo.TabIndex = 17
PictureBoxLogo.TabStop = False
'
' LabelRPST
'
LabelRPST.AutoSize = True
LabelRPST.BackColor = Color.Transparent
LabelRPST.Font = New Font("Ink Free", 9F, FontStyle.Regular, GraphicsUnit.Point)
LabelRPST.Location = New Point(50, 51)
LabelRPST.Name = "LabelRPST"
LabelRPST.Size = New Size(36, 15)
LabelRPST.TabIndex = 18
LabelRPST.Text = "RPST"
'
' StartForm
'
AutoScaleDimensions = New SizeF(7F, 15F)
AutoScaleMode = AutoScaleMode.Font
BackColor = Color.White
ClientSize = New Size(355, 255)
ContextMenuStrip = ContextMenuStrip1
Controls.Add(LimitNumericUpDown)
Controls.Add(FileMenuStrip)
Controls.Add(Label5)
Controls.Add(Label4)
Controls.Add(Label3)
Controls.Add(Label2)
Controls.Add(Label1)
Controls.Add(ListingComboBox)
BackColor = SystemColors.Control
ClientSize = New Size(281, 244)
ContextMenuStrip = ContextMenuStripRightClick
Controls.Add(LabelRPST)
Controls.Add(PictureBoxLogo)
Controls.Add(TimeframeComboBox)
Controls.Add(SubredditTextBox)
Controls.Add(ScrapeButton)
Controls.Add(KeywordTextBox)
Controls.Add(LabelTimeframe)
Controls.Add(LabelKeyword)
Controls.Add(ListingComboBox)
Controls.Add(LimitNumericUpDown)
Controls.Add(LabelListing)
Controls.Add(ButtonScrape)
Controls.Add(LabelLimit)
Controls.Add(LabelSubreddit)
Controls.Add(SubredditTextBox)
FormBorderStyle = FormBorderStyle.FixedSingle
Icon = CType(resources.GetObject("$this.Icon"), Icon)
MainMenuStrip = FileMenuStrip
MaximizeBox = False
Name = "StartForm"
StartPosition = FormStartPosition.CenterScreen
Text = "ProgramName ProgramVersion"
ContextMenuStrip1.ResumeLayout(False)
FileMenuStrip.ResumeLayout(False)
FileMenuStrip.PerformLayout()
ContextMenuStripRightClick.ResumeLayout(False)
CType(LimitNumericUpDown, ComponentModel.ISupportInitialize).EndInit()
CType(PictureBoxLogo, ComponentModel.ISupportInitialize).EndInit()
ResumeLayout(False)
PerformLayout()
End Sub
Friend WithEvents KeywordTextBox As TextBox
Friend WithEvents SubredditTextBox As TextBox
Friend WithEvents ScrapeButton As Button
Friend WithEvents ButtonScrape As Button
Friend WithEvents TimeframeComboBox As ComboBox
Friend WithEvents ListingComboBox As ComboBox
Friend WithEvents Label1 As Label
Friend WithEvents Label2 As Label
Friend WithEvents Label3 As Label
Friend WithEvents Label4 As Label
Friend WithEvents Label5 As Label
Friend WithEvents ContextMenuStrip1 As ContextMenuStrip
Friend WithEvents FileMenuStrip As MenuStrip
Friend WithEvents ToolsToolStripMenuTools As ToolStripMenuItem
Friend WithEvents AboutToolStripMenuItem As ToolStripMenuItem
Friend WithEvents DeveloperToolStripMenuItem As ToolStripMenuItem
Friend WithEvents ToolStripSeparator2 As ToolStripSeparator
Friend WithEvents QuitToolStripMenuItem As ToolStripMenuItem
Friend WithEvents SaveResultsStripMenuItem As ToolStripMenuItem
Friend WithEvents CheckUpdatesToolStripMenuItem As ToolStripMenuItem
Friend WithEvents JSONToolStripMenuItem As ToolStripMenuItem
Friend WithEvents CSVToolStripMenuItem As ToolStripMenuItem
Friend WithEvents LabelKeyword As Label
Friend WithEvents LabelSubreddit As Label
Friend WithEvents LabelLimit As Label
Friend WithEvents LabelListing As Label
Friend WithEvents LabelTimeframe As Label
Friend WithEvents ContextMenuStripRightClick As ContextMenuStrip
Friend WithEvents ToolStripMenuItemSavePosts As ToolStripMenuItem
Friend WithEvents ToolStripMenuItemtoJSON As ToolStripMenuItem
Friend WithEvents ToolStripMenuItemtoCSV As ToolStripMenuItem
Friend WithEvents LimitNumericUpDown As NumericUpDown
Friend WithEvents DarkModeToolStripMenuItem As ToolStripMenuItem
Friend WithEvents ToolTip1 As ToolTip
Friend WithEvents ToolStripMenuItemDarkMode As ToolStripMenuItem
Friend WithEvents ToolStripMenuItemAbout As ToolStripMenuItem
Friend WithEvents ToolStripMenuItemDeveloper As ToolStripMenuItem
Friend WithEvents ToolStripMenuItemCheckUpdates As ToolStripMenuItem
Friend WithEvents ToolStripMenuItemQuit As ToolStripMenuItem
Friend WithEvents PictureBoxLogo As PictureBox
Friend WithEvents LabelRPST As Label
End Class

File diff suppressed because it is too large Load Diff

View File

@@ -13,8 +13,8 @@ Public Class StartForm
''' </summary>
''' <param name="sender">The sender of the event.</param>
''' <param name="e">The EventArgs instance containing the event data.</param>
Private Sub ScrapeButton_Click(sender As Object, e As EventArgs) Handles ScrapeButton.Click
Utilities.ProcessRedditPosts(JSONToolStripMenuItem)
Private Sub ButtonScrape_Click(sender As Object, e As EventArgs) Handles ButtonScrape.Click
Utilities.ProcessRedditPosts(ToolStripMenuItemtoJSON)
End Sub
@@ -29,67 +29,7 @@ Public Class StartForm
settings.ToggleDarkMode(settings.DarkMode)
Utilities.PathFinder()
Utilities.LogFirstTimeLaunch()
Me.Text = My.Application.Info.AssemblyName
End Sub
''' <summary>
''' Event handler for the 'About' menu item click.
''' It shows the 'About' dialog box.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">An EventArgs that contains the event data.</param>
Private Sub AboutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AboutToolStripMenuItem.Click
AboutBox.ShowDialog()
End Sub
''' <summary>
''' Event handler for the 'Quit' menu item click.
''' It asks the user for confirmation and closes the program if the user agrees.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">An EventArgs that contains the event data.</param>
Private Sub QuitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles QuitToolStripMenuItem.Click
Dim result As DialogResult = MessageBox.Show("This will close the program, continue?", "Quit", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = DialogResult.Yes Then
Me.Close()
End If
End Sub
''' <summary>
''' Event handler for the 'Developer' menu item click.
''' It shows the 'Developer' dialog box.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">An EventArgs that contains the event data.</param>
Private Sub DeveloperToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DeveloperToolStripMenuItem.Click
DeveloperForm.ShowDialog()
End Sub
''' <summary>
''' Event handler for the 'Check Updates' menu item click.
''' It checks for application updates and provides update information if a newer version is available.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">An EventArgs that contains the event data.</param>
Private Sub CheckUpdatesToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CheckUpdatesToolStripMenuItem.Click
Dim data As JObject = ApiHandler.CheckUpdates()
If data("tag_name").ToString = $"{My.Application.Info.Version}" Then
MessageBox.Show($"You're running the current version v{My.Application.Info.Version} of {My.Application.Info.ProductName}. Check again soon! :)", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
Dim confirm As DialogResult = MessageBox.Show($"A new version v{data("tag_name")} of {My.Application.Info.ProductName} is available, would you like to get it?
What's new in v{data("tag_name")}?
{data("body")}
", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If confirm = DialogResult.Yes Then
Shell($"cmd /c start https://github.com/bellingcat/reddit-post-scraping-tool/releases/tag/{data("tag_name")}")
End If
End If
Me.Text = $"{My.Application.Info.AssemblyName} v{My.Application.Info.Version}"
End Sub
@@ -99,7 +39,65 @@ What's new in v{data("tag_name")}?
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">An EventArgs that contains the event data.</param>
Private Sub DarkModeToolStripMenuItem_CheckedChanged(sender As Object, e As EventArgs) Handles DarkModeToolStripMenuItem.CheckedChanged
settings.ToggleDarkMode(DarkModeToolStripMenuItem.Checked)
Private Sub DarkModeToolStripMenuItem_CheckedChanged(sender As Object, e As EventArgs) Handles ToolStripMenuItemDarkMode.CheckedChanged
settings.ToggleDarkMode(ToolStripMenuItemDarkMode.Checked)
End Sub
''' <summary>
''' Event handler for the 'About' menu item click.
''' It shows the 'About' box.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">An EventArgs that contains the event data.</param>
Private Sub ToolStripMenuItemAbout_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItemAbout.Click
AboutBox.Show()
End Sub
''' <summary>
''' Event handler for the 'Developer' menu item click.
''' It shows the 'Developer' dialog box.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">An EventArgs that contains the event data.</param>
Private Sub ToolStripMenuItemDeveloper_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItemDeveloper.Click
DeveloperBox.ShowDialog()
End Sub
''' <summary>
''' Event handler for the 'Check Updates' menu item click.
''' It checks for application updates and provides update information if a newer version is available.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">An EventArgs that contains the event data.</param>
Private Sub ToolStripMenuItemCheckUpdates_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItemCheckUpdates.Click
Dim data As JObject = ApiHandler.CheckUpdates()
If data("tag_name").ToString = $"{My.Application.Info.Version}" Then
MessageBox.Show($"You're running the current version v{My.Application.Info.Version} of {My.Application.Info.ProductName}. Check again soon! :)", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
Dim confirm As DialogResult = MessageBox.Show($"A new version v{data("tag_name")} of {My.Application.Info.ProductName} is available, would you like to get it?
{data("body")}
", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If confirm = DialogResult.Yes Then
Shell($"cmd /c start {data("html_url")}")
End If
End If
End Sub
''' <summary>
''' Event handler for the 'Quit' menu item click.
''' It asks the user for confirmation and closes the program if the user agrees.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">An EventArgs that contains the event data.</param>
Private Sub ToolStripMenuItemQuit_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItemQuit.Click
Dim result As DialogResult = MessageBox.Show("This will close the program, continue?", "Quit", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = DialogResult.Yes Then
Me.Close()
End If
End Sub
End Class

View File

@@ -17,7 +17,7 @@ Public Class Utilities
If inputs.HasValue Then
' Initialize the DataGridView
DataGridViewHandler.AddColumn(PostsForm.DataGridViewPosts)
DataGridViewHandler.AddColumn(ResultsForm.DataGridViewResults)
' Fetch Reddit posts based on the inputs
Dim processor As New PostsProcessor()
@@ -29,17 +29,17 @@ Public Class Utilities
For Each post In posts("data")("children")
totalPosts += 1
' Check if the post contains the keyword
If PostsProcessor.PostContainsKeyword(post, inputs.Value.Keyword.ToLower(System.Globalization.CultureInfo.InvariantCulture)) Then
If PostsProcessor.PostContainsKeyword(post, inputs.Value.Keyword.ToLower(Globalization.CultureInfo.InvariantCulture)) Then
' Add the post to the DataGridView
DataGridViewHandler.AddRow(PostsForm.DataGridViewPosts, post, totalPosts)
PostsForm.Show()
DataGridViewHandler.AddRow(ResultsForm.DataGridViewResults, post, totalPosts)
ResultsForm.Show()
keywordFound = True
End If
Next
' Check if the keyword was found in any posts
If Not keywordFound Then
MessageBox.Show($"Keyword `{inputs.Value.Keyword}` was not found in any of the " + posts("data")("children").Count.ToString(System.Globalization.CultureInfo.InvariantCulture) _
MessageBox.Show($"Keyword `{inputs.Value.Keyword}` was not found in any of the " + posts("data")("children").Count.ToString(Globalization.CultureInfo.InvariantCulture) _
+ $" {inputs.Value.Listing} posts from r/{inputs.Value.Subreddit}", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
@@ -48,7 +48,6 @@ Public Class Utilities
Utilities.SavePostsToJson(posts("data"))
End If
Else
MessageBox.Show("Inputs cannot be empty. Please enter a keyword and a subreddit.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub
@@ -88,25 +87,22 @@ Public Class Utilities
Public Shared Function CollectInputs() As (Keyword As String, Subreddit As String, Listing As String, Limit As Integer, Timeframe As String)?
Dim keyword As String = StartForm.KeywordTextBox.Text.Trim()
Dim subreddit As String = StartForm.SubredditTextBox.Text.Trim()
' Convert the Keyword and Subreddit to lowercase using InvariantCulture
Dim listing As String = If(String.IsNullOrEmpty(StartForm.ListingComboBox.Text), "top", StartForm.ListingComboBox.Text.ToLower(System.Globalization.CultureInfo.InvariantCulture).Trim())
' Convert the Listing and Subreddit to lowercase using InvariantCulture
Dim listing As String = If(String.IsNullOrEmpty(StartForm.ListingComboBox.Text), "top", StartForm.ListingComboBox.Text.ToLower(Globalization.CultureInfo.InvariantCulture).Trim())
Dim timeframe As String = If(String.IsNullOrEmpty(StartForm.TimeframeComboBox.Text), "all", StartForm.TimeframeComboBox.Text.ToLower(Globalization.CultureInfo.InvariantCulture).Trim())
Dim limit As Integer = StartForm.LimitNumericUpDown.Value
Dim timeframe As String = If(String.IsNullOrEmpty(StartForm.TimeframeComboBox.Text), "all", StartForm.TimeframeComboBox.Text.ToLower(System.Globalization.CultureInfo.InvariantCulture).Trim())
' Validate inputs
If String.IsNullOrEmpty(keyword) Then
MessageBox.Show("Keyword should not be empty", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
If String.IsNullOrEmpty(keyword) AndAlso String.IsNullOrEmpty(subreddit) Then
MessageBox.Show("Keyword and Subreddit fields should not be empty.", "Invalid Inputs", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Return Nothing
ElseIf String.IsNullOrEmpty(keyword) Then
MessageBox.Show("Keyword field should not be empty.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Return Nothing
ElseIf String.IsNullOrEmpty(subreddit) Then
MessageBox.Show("Subreddit field should not be empty.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Return Nothing
End If
If String.IsNullOrEmpty(subreddit) Then
MessageBox.Show("Subreddit should not be empty", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Return Nothing
End If
If limit > 100 Then
MessageBox.Show("Limit should not be over 100. Defaulting to 10", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
limit = 10
End If
Return (keyword, subreddit, listing, limit, timeframe)
End Function
@@ -174,7 +170,6 @@ First launched on: {DateTime.Now}"
LicenseNotice()
File.WriteAllText(filePath, textToWrite)
Else
' DO NOTHING
End If
End Sub
End Class

View File

@@ -7,7 +7,7 @@ packages = ["rpst"]
[project]
name = "reddit-post-scraping-tool"
version = "1.4.0.0"
version = "1.5.0.0"
description = "Given a subreddit name and a keyword, RPST returns all top (by default) posts that contain the specified keyword."
readme = "README.md"
requires-python = ">=3.8"

View File

@@ -17,7 +17,7 @@ def run():
try:
# Check for updates
check_updates(version_tag="1.4.0.0")
check_updates(version_tag="1.5.0.0")
# Get posts with the provided/parsed arguments
get_posts(arguments=arguments)