private void ButtonSearch_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(TextBoxTitleID.Text))
            {
                XtraMessageBox.Show("You haven't specified a title ID.", "Empty Field", MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                return;
            }

            SetStatus("Searching for game updates...");

            Titlepatch gameUpdates = HttpExtensions.GetGameUpdatesFromTitleID(TextBoxTitleID.Text);

            switch (gameUpdates)
            {
            case null:
                XtraMessageBox.Show("Unable to find details for this title ID.", "Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                break;

            default:
            {
                GridGameUpdates.DataSource = null;

                DataTable gameUpdateFiles = DataExtensions.CreateDataTable(new List <DataColumn>
                    {
                        new("File URL", typeof(string)),
                        new("File SHA1", typeof(string)),
                        new("File Name", typeof(string)),
                        new("File Version", typeof(string)),
                        new("File Size", typeof(string)),
                        new("System Version", typeof(string))
                    });

                string gameTitle = Regex.Replace(gameUpdates.Tag.Package.Last().Paramsfo.TITLE, @"\(.*?\)", "").Trim().Replace("®", "®");
                gameUpdates.Tag.Package.Reverse();

                foreach (Package update in gameUpdates.Tag.Package)
                {
                    gameUpdateFiles.Rows.Add(
                        update.Url,
                        update.Sha1sum,
                        gameTitle,
                        "v" + update.Version.RemoveFirstInstanceOfString("0"),
                        MainWindow.Settings.UseFormattedFileSizes
                                    ? long.Parse(update.Size).Bytes().Humanize("#")
                                    : update.Size + " Bytes",
                        "v" + update.Ps3_system_ver.RemoveFirstInstanceOfString("0").Replace("000", "00"));
                }

                GridGameUpdates.DataSource = gameUpdateFiles;

                GridViewGameUpdates.Columns[0].Visible = false;
                GridViewGameUpdates.Columns[1].Visible = false;
                //GridViewGameUpdates.Columns[2].Width = 325;
                GridViewGameUpdates.Columns[3].Width = 52;
                GridViewGameUpdates.Columns[4].Width = 85;
                GridViewGameUpdates.Columns[5].Width = 55;
                break;
            }
Beispiel #2
0
        /// <summary>
        /// </summary>
        /// <param name="titleId"> </param>
        /// <returns> </returns>
        public static string GetGameTitleFromTitleID(string titleId)
        {
            try
            {
                ServicePointManager.ServerCertificateValidationCallback = (_, _, _, _) => true;

                using WebClient webClient = new WebClient();
                XmlSerializer serializer = new XmlSerializer(typeof(Titlepatch));
                string        titlePath  = webClient.DownloadString("https://a0.ww.np.dl.playstation.net/tpl/np/" + titleId + "/" + titleId + "-ver.xml");
                using TextReader textReader = new StringReader(titlePath);
                Titlepatch data     = (Titlepatch)serializer.Deserialize(textReader);
                string     removeId = Regex.Replace(data.Tag.Package.Last().Paramsfo.TITLE, @"\(.*?\)", "").Trim().Replace("®", "®");
                return(removeId);
            }
            catch (Exception ex)
            {
                Program.Log.Error(ex, "Unable to fetch game title from ID: {0}", titleId);
                return("Not Recognized");
            }
        }