Skip to content

Commit

Permalink
Add engine detection feature
Browse files Browse the repository at this point in the history
This feature is still under development and it is **very** simple.
Don't expect magic.
  • Loading branch information
fgRuslan committed May 29, 2020
1 parent a57ecb5 commit d803bd9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Detector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class Detector

public static String detectEngine(String url)
{
if (url.StartsWith("http://"))
url = url.Substring(7);
if (url.StartsWith("https://"))
url = url.Substring(8);
foreach (var pair in engines)
{
if(url.StartsWith(pair.Key))
Expand Down
2 changes: 1 addition & 1 deletion Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private void Form1_Load(object sender, EventArgs e)
toolTip1.ReshowDelay = 250;
// Force the ToolTip text to be displayed whether or not the form is active.
toolTip1.ShowAlways = true;
toolTip1.SetToolTip(this.checkBox1, "It's better to keep this checkbox checked as if it's not, you may not be able to download everything successfully");
toolTip1.SetToolTip(this.detectButton, "Click here if you don't know what engine does the selected website uses. Keep in mind that engine detection feature is experimental.");
}

public void TagsGotFocus(object sender, EventArgs e)
Expand Down Expand Up @@ -128,7 +128,16 @@ private async void downloadButton_Click(object sender, EventArgs e)

private void detectButton_Click(object sender, EventArgs e)
{
Detector.detectEngine(domainBox.Text);
string engine = Detector.detectEngine(domainBox.Text);
switch (engine)
{
case "Dan":
isDanbooruSite.Checked = true;
break;
case "Gel":
isDanbooruSite.Checked = false;
break;
}
}

private void checkBox1_CheckedChanged(object sender, EventArgs e)
Expand Down

0 comments on commit d803bd9

Please sign in to comment.