Skip to content

Commit

Permalink
added shorter timeout and multiple html attempts, added additional ra…
Browse files Browse the repository at this point in the history
…w view, added basic sorting, added status bar
  • Loading branch information
mikeloeven committed Nov 29, 2014
1 parent 1011062 commit 757887f
Show file tree
Hide file tree
Showing 17 changed files with 225 additions and 13 deletions.
Binary file modified SBoxModList.suo
Binary file not shown.
11 changes: 11 additions & 0 deletions SBoxModList/ClassDiagram1.cd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="SBoxModList.Form1" Collapsed="true">
<Position X="0.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAwAAAACiAABAAAEKAAAACIAACAAAAAEAAAEAAAAI=</HashCode>
<FileName>Form1.cs</FileName>
</TypeIdentifier>
</Class>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>
75 changes: 69 additions & 6 deletions SBoxModList/Form1.Designer.cs

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

146 changes: 142 additions & 4 deletions SBoxModList/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,24 @@
using System.Net;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Linq;
namespace SBoxModList
{

public class WebTimeout : WebClient
{
protected override WebRequest GetWebRequest(Uri uri)
{
WebRequest w = base.GetWebRequest(uri);
w.Timeout = 5000;
return w;
}
}
public partial class Form1 : Form
{

OpenFileDialog ofd = new OpenFileDialog();
WebClient web = new WebClient();
WebTimeout web = new WebTimeout();
XPathDocument SBCFile;
XPathNavigator nav;
XPathNodeIterator modListIt;
Expand All @@ -28,22 +40,106 @@ public Form1()
InitializeComponent();
}

public struct ModInfo
{
public String ID;
public String title;
public String URL;
}
public List<ModInfo> ModList = new List<ModInfo>();


private void button1_Click(object sender, EventArgs e)
{



try
{

if (ofd.ShowDialog() == DialogResult.OK)
{


lblLoad.Text = "Loading: ";
String fName = ofd.FileName;
String sFName = ofd.FileName;
SBCFile = new XPathDocument(fName);
nav = SBCFile.CreateNavigator();
modListIt = nav.Select("//ModItem/PublishedFileId");

/*
txtOutRAW.Clear();
while (modListIt.MoveNext())
{
txtOutRAW.AppendText(modListIt.Current.InnerXml + "\r\n");
}
*/



ModList.Clear();

while (modListIt.MoveNext())
{
ModInfo modInfo = new ModInfo();
modInfo.ID = modListIt.Current.InnerXml;
modInfo.URL = "http://steamcommunity.com/sharedfiles/filedetails/?id=" + modInfo.ID;
int failcount = 0;
do{
try
{

string workshopPage = web.DownloadString(modInfo.URL);
System.Threading.Thread.Sleep(500);
modInfo.title = Regex.Match(workshopPage, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", RegexOptions.IgnoreCase).Groups["Title"].Value;
modInfo.title = modInfo.title.Replace("Steam Workshop :: ", "");
if (failcount > 0) failcount = 0;

}
catch (Exception)
{
modInfo.title = "URL Timed Out";
failcount++;
}
}while(failcount>0&&failcount<4);
ModList.Add(modInfo);
lblLoad.Text += "|";
if(lblLoad.Text.TakeWhile(c => c == '|').Count()>10)
{
lblLoad.Text = "Loading: ";
}

lblLoad.Refresh();
Application.DoEvents();
System.Threading.Thread.Sleep(500);





}

ModList = ModList.OrderBy(m => m.ID).ToList();

txtOutRAW.Clear();
txtOut.Clear();
foreach (ModInfo MI in ModList)
{
txtOutRAW.AppendText(MI.ID + "\r\n");
StringBuilder tOut = new StringBuilder();
tOut.Append("ModID: " + MI.ID + " ");
tOut.Append("ModName: " + MI.title + " ");
tOut.Append("Workshop URL: " + MI.URL + "\r\n");
txtOut.AppendText(tOut.ToString());
}
lblLoad.Text = "File Loaded";

//old code deprecated
/*
while (modListIt.MoveNext())
{
StringBuilder outputStr = new StringBuilder();
Expand All @@ -66,7 +162,7 @@ private void button1_Click(object sender, EventArgs e)
}

*/



Expand All @@ -75,10 +171,14 @@ private void button1_Click(object sender, EventArgs e)


}

else { txtOutRAW.Text = "Unable To Read File"; }


}
catch (Exception)
{

txtOutRAW.Text = "An Unknown Error Has Occurred";
}


Expand All @@ -89,5 +189,43 @@ private void txtOut_LinkClicked(Object sender, LinkClickedEventArgs e)
Process.Start(e.LinkText);
}

private void btnSName_Click(object sender, EventArgs e)
{
ModList = ModList.OrderBy(m => m.title).ToList();

txtOutRAW.Clear();
txtOut.Clear();
foreach (ModInfo MI in ModList)
{
txtOutRAW.AppendText(MI.ID + "\r\n");
StringBuilder tOut = new StringBuilder();
tOut.Append("ModName: " + MI.title + " ");
tOut.Append("ModID: " + MI.ID + " ");
tOut.Append("Workshop URL: " + MI.URL + "\r\n");
txtOut.AppendText(tOut.ToString());
}
}

private void btnSID_Click(object sender, EventArgs e)
{
ModList = ModList.OrderBy(m => m.ID).ToList();

txtOutRAW.Clear();
txtOut.Clear();
foreach (ModInfo MI in ModList)
{
txtOutRAW.AppendText(MI.ID + "\r\n");
StringBuilder tOut = new StringBuilder();
tOut.Append("ModID: " + MI.ID + " ");
tOut.Append("ModName: " + MI.title + " ");
tOut.Append("Workshop URL: " + MI.URL + "\r\n");
txtOut.AppendText(tOut.ToString());
}
}





}
}
3 changes: 2 additions & 1 deletion SBoxModList/SBoxModList.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
<SubType>Component</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
Expand All @@ -79,6 +79,7 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="ClassDiagram1.cd" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down
Binary file added SBoxModList/bin/Release/SBoxModList-1.0.zip
Binary file not shown.
Binary file modified SBoxModList/bin/Release/SBoxModList.exe
Binary file not shown.
Binary file modified SBoxModList/bin/Release/SBoxModList.pdb
Binary file not shown.
Binary file added SBoxModList/bin/Release/SBoxModList.vshost.zip
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
D:\Software Projects\SBoxModList\SBoxModList\bin\Release\SBoxModList.exe
D:\Software Projects\SBoxModList\SBoxModList\bin\Release\SBoxModList.pdb
D:\Software Projects\SBoxModList\SBoxModList\obj\x86\Release\SBoxModList.Form1.resources
D:\Software Projects\SBoxModList\SBoxModList\obj\x86\Release\SBoxModList.WebTimeout.resources
D:\Software Projects\SBoxModList\SBoxModList\obj\x86\Release\SBoxModList.Properties.Resources.resources
D:\Software Projects\SBoxModList\SBoxModList\obj\x86\Release\SBoxModList.csproj.GenerateResource.Cache
D:\Software Projects\SBoxModList\SBoxModList\obj\x86\Release\SBoxModList.exe
D:\Software Projects\SBoxModList\SBoxModList\obj\x86\Release\SBoxModList.pdb
D:\Software Projects\SBoxModList\SBoxModList\obj\x86\Release\SBoxModList.csprojResolveAssemblyReference.cache
Binary file not shown.
Binary file not shown.
Binary file modified SBoxModList/obj/x86/Release/SBoxModList.exe
Binary file not shown.
Binary file modified SBoxModList/obj/x86/Release/SBoxModList.pdb
Binary file not shown.
Binary file modified ScreenShot.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 757887f

Please sign in to comment.