Skip to content

Commit

Permalink
v0.8.8.0-beta
Browse files Browse the repository at this point in the history
Added raw and builbot server switch
  • Loading branch information
StellarUpdater committed Jun 4, 2018
1 parent 6bced72 commit 24a3788
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.7.1-beta
0.8.8.0-beta
3 changes: 2 additions & 1 deletion source/Stellar/Download.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public partial class Download
//public static Thread worker = null;

// Web Downloads
//public static WebClient wc = new WebClient();
//public static WebClient webclient = new WebClient();
//public static WebClient wc2 = new WebClient();
public static ManualResetEvent waiter = new ManualResetEvent(false); // Download one at a time

Expand Down Expand Up @@ -360,6 +360,7 @@ public static void RetroArchDownload(MainWindow mainwindow)

progressInfo = "Preparing Download...";

//MessageBox.Show(Parse.nightlyUrl); //debug
Uri downloadUrl = new Uri(Parse.nightlyUrl); // Parse.nightlyUrl = x84/x86_64 + Parse.nightly7z
//Uri downloadUrl = new Uri("http://127.0.0.1:8888/RetroArch.7z"); // TESTING Virtual Server URL

Expand Down
29 changes: 25 additions & 4 deletions source/Stellar/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs
public static void ClearRetroArchVars()
{
Parse.parseUrl = string.Empty;
Parse.page = string.Empty;
Parse.element = string.Empty;
Parse.nightly7z = string.Empty;
Parse.nightlyUrl = string.Empty;
Download.extractArgs = string.Empty;

Parse.stellar7z = string.Empty;
Expand Down Expand Up @@ -686,6 +689,15 @@ private void buttonCheck_Click(object sender, RoutedEventArgs e)
//Download.waiter.Reset();
//Download.waiter = new ManualResetEvent(false);

// Clear RetroArch Nightlies List before each run
if (Queue.NightliesList != null)
{
Queue.NightliesList.Clear();
Queue.NightliesList.TrimExcess();
}

//var message = string.Join(Environment.NewLine, Queue.NightliesList); //debug
//MessageBox.Show(message); //debug

// Progress Info
textBlockProgressInfo.Text = "Checking...";
Expand Down Expand Up @@ -828,8 +840,18 @@ private void buttonCheck_Click(object sender, RoutedEventArgs e)
// Launches Download and 7-Zip Extraction
private void buttonUpdate_Click(object sender, RoutedEventArgs e)
{
Download.waiter.Reset();
Download.waiter = new ManualResetEvent(false);
//Download.waiter.Reset();
//Download.waiter = new ManualResetEvent(false);

// Clear RetroArch Nightlies List before each run
if (Queue.NightliesList != null)
{
Queue.NightliesList.Clear();
Queue.NightliesList.TrimExcess();
}

//var message = string.Join(Environment.NewLine, Queue.NightliesList); //debug
//MessageBox.Show(message); //debug

// Add backslash to Location Textbox path if missing
if (!textBoxLocation.Text.EndsWith("\\") && !string.IsNullOrWhiteSpace(textBoxLocation.Text))
Expand Down Expand Up @@ -946,9 +968,8 @@ private void buttonUpdate_Click(object sender, RoutedEventArgs e)


// -----------------------------------------------
// If RetroArch+Cores or Cores Only Update
// RetroArch+Cores or Cores Only Update
// -----------------------------------------------
// RA+Cores or Cores Selected
if ((string)comboBoxDownload.SelectedItem == "New Install"
|| (string)comboBoxDownload.SelectedItem == "RA+Cores"
|| (string)comboBoxDownload.SelectedItem == "Cores"
Expand Down
237 changes: 216 additions & 21 deletions source/Stellar/Parse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,88 @@ public static void ParseGitHubReleases(MainWindow mainwindow)
}


// -----------------------------------------------
// Download Server Page
// -----------------------------------------------
public static void DownloadServerPage(MainWindow mainwindow)
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

// -------------------------
// If GZip disabled, switch to Uncomprssed
// -------------------------
//try
//{
// // -------------------------
// // GZip
// // -------------------------

// //MessageBox.Show(parseUrl); //debug

// // Parse the HTML Page from parseUrl
// HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(parseUrl);
// req.UserAgent = "MOZILLA/5.0 (WINDOWS NT 6.1; WOW64) APPLEWEBKIT/537.1 (KHTML, LIKE GECKO) CHROME/21.0.1180.75 SAFARI/537.1";
// req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
// req.Headers.Add("Accept-Encoding", "gzip,deflate");

// GZipStream zip = new GZipStream(req.GetResponse().GetResponseStream(), CompressionMode.Decompress);
// //zip.Position = 0;
// StreamReader reader = new StreamReader(zip);

// //MessageBox.Show("Using GZip"); //debug
// mainwindow.textBlockProgressInfo.Text = "Using GZip";

// page = reader.ReadToEnd(); // Error here if uncompressed, triggers catch

// // Close
// req.Abort();
// zip.Dispose();
// reader.Dispose();

// //MessageBox.Show("complete"); //debug
//}

//// GZip Disabled
//catch
//{
//MessageBox.Show("Page Reader Error Detected"); //debug

// -------------------------
// Uncompressed
// -------------------------

//MessageBox.Show("Using Uncompressed"); //debug
//mainwindow.textBlockProgressInfo.Text = "Using Uncompressed";

// Switch to Uncompressed download method
//WebClient wc = new WebClient();
//wc.Headers[HttpRequestHeader.UserAgent] = "MOZILLA/5.0 (WINDOWS NT 6.1; WOW64) APPLEWEBKIT/537.1 (KHTML, LIKE GECKO) CHROME/21.0.1180.75 SAFARI/537.1";
//page = wc.DownloadString(parseUrl);
//wc.Dispose();

//MessageBox.Show("complete"); //debug



// Parse the HTML Page from parseUrl
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(parseUrl);
req.UserAgent = "MOZILLA/5.0 (WINDOWS NT 6.1; WOW64) APPLEWEBKIT/537.1 (KHTML, LIKE GECKO) CHROME/21.0.1180.75 SAFARI/537.1";
req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
//req.Headers.Add("Accept-Encoding", "gzip,deflate");

HttpWebResponse response = (HttpWebResponse)req.GetResponse();

using (StreamReader sr = new StreamReader(response.GetResponseStream()))
{
page = sr.ReadToEnd();
}

//MessageBox.Show(page); //debug
//}
}


// -----------------------------------------------
// Parse Builbot Page HTML
// -----------------------------------------------
Expand All @@ -173,34 +255,38 @@ public static void ParseBuildbotPage(MainWindow mainwindow)
if ((string)mainwindow.comboBoxDownload.SelectedItem == "RetroArch"
|| (string)mainwindow.comboBoxDownload.SelectedItem == "RA+Cores")
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
// Clear RetroArch Nightlies List
if (Queue.NightliesList != null)
{
Queue.NightliesList.Clear();
Queue.NightliesList.TrimExcess();
}

//var message = string.Join(Environment.NewLine, Queue.NightliesList); //debug
//MessageBox.Show(message); //debug

// -------------------------
// Update Selected
// -------------------------
try
{
// Parse the HTML Page from parseUrl
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(parseUrl);
req.UserAgent = "MOZILLA/5.0 (WINDOWS NT 6.1; WOW64) APPLEWEBKIT/537.1 (KHTML, LIKE GECKO) CHROME/21.0.1180.75 SAFARI/537.1";
req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
req.Headers.Add("Accept-Encoding", "gzip,deflate");

GZipStream zip = new GZipStream(req.GetResponse().GetResponseStream(), CompressionMode.Decompress);
var reader = new StreamReader(zip);
var page = reader.ReadToEnd();
// Default Server to Raw
libretro_x86 = "https://raw.libretro.com/nightly/windows/x86/"; // Download URL 32-bit
libretro_x86_64 = "https://raw.libretro.com/nightly/windows/x86_64/"; // Download URL 64-bit
libretro_x86_64_w32 = "https://raw.libretro.com/nightly/windows/x86_64_w32/"; // Download URL 64-bit w32

req.Abort();
zip.Dispose();
reader.Dispose();
// Parse the HTML Page from parseUrl
DownloadServerPage(mainwindow);

// HTML Tag containing Dated 7z, (.*?) is the text to keep
element = "<a href=\"/nightly/windows/" + Paths.buildbotArchitecture + "/(.*?)\">";

// Find 7z Matches in HTML tags
MatchCollection matches = Regex.Matches(page, element);

//var message = string.Join(Environment.NewLine, Queue.NightliesList); //debug
//MessageBox.Show(message); //debug

if (matches.Count > 0)
{
foreach (Match m in matches)
Expand All @@ -216,20 +302,125 @@ public static void ParseBuildbotPage(MainWindow mainwindow)
Queue.NightliesList.TrimExcess();
}

// Sort the Nighlies List, lastest 7z is first
Queue.NightliesList.Sort(); //do not disable this sort
// Clear RetroArch Nightlies List
if (Queue.NightliesList != null)
{
Queue.NightliesList.Clear();
Queue.NightliesList.TrimExcess();
}

//var message = string.Join(Environment.NewLine, Queue.NightliesList); //debug
//MessageBox.Show(message);
//message = string.Join(Environment.NewLine, Queue.NightliesList); //debug
//MessageBox.Show(message); //debug

// Switch Raw to Buildbot if no matches found
//
// -------------------------
// Raw Server
// -------------------------
if (Queue.NightliesList.Count > 0)
{
MessageBox.Show("Using Raw"); //debug
mainwindow.textBlockProgressInfo.Text = "Using Raw";

try
{
// Sort the Nighlies List, lastest 7z is first
Queue.NightliesList.Sort(); //do not disable this sort

//var message = string.Join(Environment.NewLine, Queue.NightliesList); //debug
//MessageBox.Show(message); //debug

// Get Lastest Element of Nightlies List
nightly7z = Queue.NightliesList.Last();

if (Queue.NightliesList != null)
{
Queue.NightliesList.Clear();
Queue.NightliesList.TrimExcess();
}
}
catch
{
MainWindow.ready = false;
MessageBox.Show("Error: Problem creating RetroArch list from HTML.");
}

}

// -------------------------
// Buildbot Server (Backup)
// -------------------------
else
{
//MessageBox.Show("Using Buildbot"); //debug
mainwindow.textBlockProgressInfo.Text = "Using Buildbot";

// Change Server to Buildbot
libretro_x86 = "https://buildbot.libretro.com/nightly/windows/x86/"; // Download URL 32-bit
libretro_x86_64 = "https://buildbot.libretro.com/nightly/windows/x86_64/"; // Download URL 64-bit
libretro_x86_64_w32 = "https://buildbot.libretro.com/nightly/windows/x86_64_w32/"; // Download URL 64-bit w32

// Reset Achitecture
Paths.SetArchitecture(mainwindow);
// Show URL in Textbox
Paths.SetUrls(mainwindow);

// Parse the HTML Page from parseUrl
DownloadServerPage(mainwindow);

// HTML Tag containing Dated 7z, (.*?) is the text to keep
element = "<a href=\"/nightly/windows/" + Paths.buildbotArchitecture + "/(.*?)\">";

// Find 7z Matches in HTML tags
matches = Regex.Matches(page, element);

if (matches.Count > 0)
{
foreach (Match m in matches)
{
Queue.NightliesList.Add(m.Groups[1].Value);
}

//MessageBox.Show("Matches found: {0}", string.Join(Environment.NewLine, matches.Count)); //debug

// Remove from the List all 7z files that do not contain _RetroArch.7z (filters out unwanted)
Queue.NightliesList.RemoveAll(u => !u.Contains("_RetroArch.7z"));

Queue.NightliesList.TrimExcess();
}

//var message = string.Join(Environment.NewLine, Queue.NightliesList); //debug
//MessageBox.Show(message); //debug


try
{
// Sort the Nighlies List, lastest 7z is first
Queue.NightliesList.Sort(); //do not disable this sort

// Get Lastest Element of Nightlies List
nightly7z = Queue.NightliesList.Last();

if (Queue.NightliesList != null)
{
Queue.NightliesList.Clear();
Queue.NightliesList.TrimExcess();
}
}
catch
{
MainWindow.ready = false;
MessageBox.Show("Error: Problem creating RetroArch list from HTML.");
}
}

// Get Lastest Element of Nightlies List
nightly7z = Queue.NightliesList.Last();
}
catch
{
MainWindow.ready = false;
MessageBox.Show("Error: Problem creating RetroArch list from HTML.");
MessageBox.Show("Error: Problem connecting to Network.");
}

}

// -------------------------
Expand Down Expand Up @@ -280,6 +471,10 @@ public static void ParseBuildbotPage(MainWindow mainwindow)
{
// Create URL string for Uri
nightlyUrl = libretro_x86_64 + nightly7z;

//MessageBox.Show(libretro_x86_64); //debug
//MessageBox.Show(nightly7z); //debug
//MessageBox.Show(nightlyUrl); //debug
}


Expand Down
4 changes: 2 additions & 2 deletions source/Stellar/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.8.7.1")]
[assembly: AssemblyFileVersion("0.8.7.1")]
[assembly: AssemblyVersion("0.8.8.0")]
[assembly: AssemblyFileVersion("0.8.8.0")]

0 comments on commit 24a3788

Please sign in to comment.