Skip to content

Instantly share code, notes, and snippets.

@Tustin
Created July 12, 2017 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tustin/517f482fecbdabc2bbac7a6c6d1cf4b6 to your computer and use it in GitHub Desktop.
Save Tustin/517f482fecbdabc2bbac7a6c6d1cf4b6 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Security;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace pkgfinder
{
class Program
{
public class PackageData
{
public string GameVersion { get; set; }
public long Size { get; set; }
public string Checksum { get; set; }
public string Url { get; set; }
public string Ps3Version { get; set; }
}
static void Main(string[] args)
{
var res = GetPackageData("https://a0.ww.np.dl.playstation.net/tpl/np/BLUS30377/BLUS30377-ver.xml");
foreach (var package in res)
{
Console.WriteLine(package.Url);
}
Console.ReadKey();
}
static List<PackageData> GetPackageData(string url)
{
var result = new List<PackageData>();
XmlDocument doc = new XmlDocument();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.AutomaticDecompression = DecompressionMethods.GZip;
//Hack to ignore trust issues with request
ServicePointManager.ServerCertificateValidationCallback = new
RemoteCertificateValidationCallback
(
delegate { return true; }
);
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
string resp = reader.ReadToEnd();
doc.LoadXml(resp);
XmlNodeList packages = doc.GetElementsByTagName("package");
for (int i = 0; i < packages.Count; i++)
{
var package = packages[i];
PackageData data = new PackageData()
{
GameVersion = package.Attributes["version"].Value,
Size = Convert.ToInt64(package.Attributes["size"].Value),
Checksum = package.Attributes["sha1sum"].Value,
Ps3Version = package.Attributes["ps3_system_ver"].Value,
Url = package.Attributes["url"].Value,
};
result.Add(data);
}
}
return result;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment