Skip to content

Commit

Permalink
Checking hash before attempting to download now. Found out that some …
Browse files Browse the repository at this point in the history
…comics still use the old hash location.
  • Loading branch information
fireshaper committed Jul 17, 2019
1 parent 19008df commit 2611527
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 12 deletions.
45 changes: 39 additions & 6 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Omnibus
public partial class Form1 : Form
{

private String version = "1.4.0";
private String version = "1.4.2";
private String url = "https://getcomics.info/?s=";
private int cancelled = 0;
private int complete;
Expand Down Expand Up @@ -185,13 +185,28 @@ private void btnDownload_Click(object sender, EventArgs e)
//MessageBox.Show("Found in:" + i);
string[] g3 = g1[i].Split('"');

//string gcURL = g3[5];
//string[] gcURLArray = gcURL.Split('/');
string gcURL = g3[5];
string[] gcURLArray = gcURL.Split('/');

//string encodedValue = gcURLArray[4]; //old code had hash in another location
string encodedValue1 = gcURLArray[4]; //first hash location

string gcURL = g3[0]; //updated location of hash
string encodedValue = gcURL;
gcURL = g3[0];
string encodedValue2 = gcURL; //second hash location

string encodedValue = "";

if (IsBase64(encodedValue1) == true)
{
encodedValue = encodedValue1;
}
else if (IsBase64(encodedValue2) == true)
{
encodedValue = encodedValue2;
}
else
{
MessageBox.Show("No downloads available, go to the comic's page to download.");
}

if (lastEV != encodedValue)
{
Expand Down Expand Up @@ -750,5 +765,23 @@ private void LogWriter(string line)
string datetime = DateTime.Now.ToString("MM-dd-yy HH:mm:ss");
File.AppendAllText(@"log.txt", "(" + datetime + ") - " + line + Environment.NewLine);
}

public static bool IsBase64(string base64String)
{
if (string.IsNullOrEmpty(base64String) || base64String.Length % 4 != 0
|| base64String.Contains(" ") || base64String.Contains("\t") || base64String.Contains("\r") || base64String.Contains("\n"))
return false;

try
{
Convert.FromBase64String(base64String);
return true;
}
catch (Exception exception)
{
Console.WriteLine("Exception caught: {0}", e);
}
return false;
}
}
}
11 changes: 5 additions & 6 deletions obj/Debug/Omnibus.csproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
C:\Users\rory5\source\repos\Omnibus\Comic Search\obj\Debug\Omnibus.Form1.resources
C:\Users\rory5\source\repos\Omnibus\Comic Search\obj\Debug\Omnibus.Properties.Resources.resources
C:\Users\rory5\source\repos\Omnibus\Comic Search\obj\Debug\Omnibus.Settings.resources
C:\Users\rory5\source\repos\Omnibus\Comic Search\obj\Debug\Omnibus.csproj.GenerateResource.cache
C:\Users\rory5\source\repos\Omnibus\Comic Search\obj\Debug\Omnibus.csproj.CoreCompileInputs.cache
C:\Users\rory5\source\repos\Omnibus\Comic Search\bin\Debug\Omnibus.exe.config
C:\Users\rory5\source\repos\Omnibus\Comic Search\bin\Debug\Omnibus.exe
C:\Users\rory5\source\repos\Omnibus\Comic Search\bin\Debug\Omnibus.pdb
Expand All @@ -8,12 +13,6 @@ C:\Users\rory5\source\repos\Omnibus\Comic Search\bin\Debug\HtmlAgilityPack.pdb
C:\Users\rory5\source\repos\Omnibus\Comic Search\bin\Debug\HtmlAgilityPack.xml
C:\Users\rory5\source\repos\Omnibus\Comic Search\bin\Debug\MegaApiClient.xml
C:\Users\rory5\source\repos\Omnibus\Comic Search\bin\Debug\Newtonsoft.Json.xml
C:\Users\rory5\source\repos\Omnibus\Comic Search\obj\Debug\Omnibus.Form1.resources
C:\Users\rory5\source\repos\Omnibus\Comic Search\obj\Debug\Omnibus.Properties.Resources.resources
C:\Users\rory5\source\repos\Omnibus\Comic Search\obj\Debug\Omnibus.Settings.resources
C:\Users\rory5\source\repos\Omnibus\Comic Search\obj\Debug\Omnibus.csproj.GenerateResource.cache
C:\Users\rory5\source\repos\Omnibus\Comic Search\obj\Debug\Omnibus.csproj.CoreCompileInputs.cache
C:\Users\rory5\source\repos\Omnibus\Comic Search\obj\Debug\Omnibus.csproj.CopyComplete
C:\Users\rory5\source\repos\Omnibus\Comic Search\obj\Debug\Omnibus.exe
C:\Users\rory5\source\repos\Omnibus\Comic Search\obj\Debug\Omnibus.pdb
C:\Users\rory5\source\repos\Omnibus\Comic Search\obj\Debug\Omnibus.csprojAssemblyReference.cache

0 comments on commit 2611527

Please sign in to comment.