예제 #1
0
            public int ParseOnSale(string content)
            {
                InventList.Clear();
                string parseBody = Regex.Match(content, "(?<=section market_home_listing_table\">)(.*)(?=<div id=\"tabContentsMyMarketHistory)",
                                               RegexOptions.Singleline).ToString();

                MatchCollection matches = Regex.Matches(parseBody, "(?<=market_recent_listing_row listing_)(.*?)(?=	</div>\r\n</div>)",
                                                        RegexOptions.Singleline);

                if (matches.Count != 0)
                {
                    foreach (Match match in matches)
                    {
                        string currmatch = match.Groups[1].Value;

                        string ImgLink = Regex.Match(currmatch, "(?<=economy/image/)(.*)(?=/38fx38f)").ToString();

                        //If you need:
                        //string assetid = Regex.Match(currmatch, "(?<='mylisting', ')(.*)(?=\" class=\"item_market)").ToString();
                        //assetid = assetid.Substring(assetid.Length - 11, 9);

                        string listId = Regex.Match(currmatch, "(?<=mylisting_)(.*)(?=_image\" src=)").ToString();

                        string appidRaw = Regex.Match(currmatch, "(?<=market_listing_item_name_link)(.*)(?=</a></span>)").ToString();
                        string pageLnk  = Regex.Match(appidRaw, "(?<=href=\")(.*)(?=\">)").ToString();

                        string captainPrice = Regex.Match(currmatch, @"(?<=>
						)(.*)(?=					</span>
					<br>)"                    , RegexOptions.Singleline).ToString();

                        captainPrice = SteamLibrary.GetSweetPrice(Regex.Replace(captainPrice,
                                                                                Currencies.GetAscii(), string.Empty).Trim());

                        captainPrice.Insert(captainPrice.Length - 2, ".");

                        string[] LinkName = Regex.Match(currmatch, "(?<=_name_link\" href=\")(.*)(?=</a></span><br/>)").
                                            ToString().Split(new string[] { "\">" }, StringSplitOptions.None);

                        string ItemType = Regex.Match(currmatch, "(?<=_listing_game_name\">)(.*)(?=</span>)").ToString();

                        InventList.Add(new SteamLibrary.InventItem(listId, LinkName[1], ItemType, captainPrice, "0", ImgLink,
                                                                   string.Empty, true, true, pageLnk));
                    }
                }
                //else
                //TODO. Add correct error processing
                //MessageBox.Show(Strings.OnSaleErr, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);

                return(matches.Count);
            }
예제 #2
0
            public int ParseInventory(string content)
            {
                InventList.Clear();

                try
                {
                    var rgDescr = JsonConvert.DeserializeObject <SteamLibrary.InventoryData>(content);

                    foreach (SteamLibrary.InvItem prop in rgDescr.myInvent.Values)
                    {
                        var ourItem = rgDescr.invDescr[prop.classid + "_" + prop.instanceid];

                        //parse cost by url (_lists + 753/ + ourItem.MarketName)
                        string price = "0";

                        if (!ourItem.Marketable)
                        {
                            price = "1";
                        }

                        //fix for special symbols in Item Name
                        string markname = string.Empty;

                        if ((ourItem.MarketName == null) && (ourItem.Name == string.Empty))
                        {
                            ourItem.Name       = ourItem.SimpleName;
                            ourItem.MarketName = ourItem.SimpleName;
                        }

                        //BattleBlock Theater Fix
                        markname = Uri.EscapeDataString(ourItem.MarketName);
                        string pageLnk = string.Format("{0}/{1}/{2}", SteamLibrary._lists, ourItem.AppId, markname);

                        InventList.Add(new SteamLibrary.InventItem(prop.assetid, ourItem.Name, ourItem.Type,
                                                                   price, "0", ourItem.IconUrl, ourItem.MarketName, false, ourItem.Marketable, pageLnk));
                    }
                }
                catch (Exception e)
                {
                    SteamLibrary.AddtoLog(e.Message);
                }

                return(InventList.Count);
            }