public StoreItem ConvertItem(Entry entry) { var ret = new StoreItem(); if (entry.MetaInfo != null) { foreach (var mi in entry.MetaInfo) { switch (mi.Key) { case "EncryptionKey": Index.UseKey(Convert.FromBase64String(mi.Value.Split(':', 3)[1])); break; case "BannerOverride": ret.Banner = mi.Value.ToUpperInvariant(); break; } } } var displayAssetPath = entry.DisplayAssetPath ?? "None"; var _p = GetItemPath(entry.ItemGrants[0].TemplateID, out ret.Type); Console.WriteLine("Getting " + _p); var exp = Index.GetPackage(_p).GetExport <UObject>(); foreach (var prop in exp) { switch (prop.Key) { case "Rarity": if (ret.Rarity == Rarity.UNCOMMON) { ret.Rarity = GetRarity((EnumProperty)prop.Value); } break; case "DisplayName": ret.Name = ((TextProperty)prop.Value).Value; break; case "ShortDescription": ret.ShortDescription = ((TextProperty)prop.Value).Value; break; case "Description": ret.Description = ((TextProperty)prop.Value).Value; break; case "Series": ret.Series = ((ObjectProperty)prop.Value).Value.Resource.ObjectName.String.ToLowerInvariant(); break; case "DisplayAssetPath": if (displayAssetPath == "None") { displayAssetPath = ((FSoftObjectPath)((StructProperty)prop.Value).Value).AssetPathName.String; } break; case "LargePreviewImage": if (ret.StandardIcon == null) { ret.StandardIcon = ((SoftObjectProperty)prop.Value).Value.AssetPathName.String; } break; case "HeroDefinition": // skin foreach (var defProp in Index.GetPackage("/FortniteGame/Content/Athena/Heroes/" + ((ObjectProperty)prop.Value).Value.Resource.ObjectName.String).GetExport <UObject>()) { switch (defProp.Key) { case "LargePreviewImage": ret.StandardIcon = ((SoftObjectProperty)defProp.Value).Value.AssetPathName.String; break; } } break; case "WeaponDefinition": // pick var path = "/FortniteGame/Content/Athena/Items/Weapons/" + ((ObjectProperty)prop.Value).Value.Resource.ObjectName.String; Console.WriteLine("getting pickaxe: " + path); var uobj = Index.GetPackage("/FortniteGame/Content/Athena/Items/Weapons/" + ((ObjectProperty)prop.Value).Value.Resource.ObjectName.String).GetExport <UObject>(); foreach (var defProp in uobj) { switch (defProp.Key) { case "LargePreviewImage": ret.StandardIcon = ((SoftObjectProperty)defProp.Value).Value.AssetPathName.String; break; } } break; } } if (displayAssetPath != "None") { exp = Index.GetPackage(ConvertObjectPath(displayAssetPath)).GetExport <UObject>(); foreach (var prop in exp) { switch (prop.Key) { case "DisplayName": ret.Name = ((TextProperty)prop.Value).Value; break; case "ShortDescription": ret.ShortDescription = ((TextProperty)prop.Value).Value; break; case "Description": ret.Description = ((TextProperty)prop.Value).Value; break; case "TileImage": case "DetailsImage": var ind = ((ObjectProperty)((UObject)((StructProperty)prop.Value).Value)["ResourceObject"]).Value; if (string.IsNullOrWhiteSpace(ind.Resource.ObjectName.String)) { throw new NotImplementedException("WRAPS NOT ADDED YET"); /*/ most likely an item wrap * foreach (var mProp in (await Index.GetPackage("/FortniteGame/Content/UI/Foundation/Textures/Icons/Wraps/FeaturedMaterials/" + packageIndex.import).GetUObjectAsync()).properties) * { * if (mProp.name == "TextureParameterValues") * { * ret.FeaturedIcon = ((FPackageIndex)((FStructFallback)((UScriptStruct)((UScriptArray)mProp.tag_data).data[0]).struct_type).properties[1].tag_data).outer_import; * } * }*/ } else { ret.FeaturedIcon = ind.Resource.OuterIndex.Resource.ObjectName.String; if (ret.FeaturedIcon.Contains("MI_UI")) { // yikes but whatever lol ret.FeaturedIcon = ((ObjectProperty)((UObject)((StructProperty)((ArrayProperty)Index.GetPackage(ConvertObjectPath(ret.FeaturedIcon)).GetExport <UObject>()["TextureParameterValues"]).Value[0]).Value)["ParameterValue"]).Value.Resource.OuterIndex.Resource.ObjectName.String; } } break; } } if (ret.Type == ItemType.ITEMWRAP) { ret.StandardIcon = ret.FeaturedIcon; } ret.FeaturedIcon = ConvertObjectPath(ret.FeaturedIcon); } ret.StandardIcon = ConvertObjectPath(ret.StandardIcon); if (entry.Categories.Length != 0) { ret.FeaturedCategory = int.Parse(entry.Categories[0].Split(' ', 2)[1]); } ret.SortPriority = entry.SortPriority; switch (entry.OfferType) { case "DynamicBundle": int basePrice = 0; var items = entry.BundleInfo.BundleItems; for (int i = 0; i < items.Length; i++) { basePrice += items[i].RegularPrice; } DiscountedPrice price; ret.Price = price = new DiscountedPrice(basePrice + entry.BundleInfo.DiscountedBasePrice, basePrice); switch (entry.BundleInfo.DisplayType) { case "PercentOff": ret.Banner = $"{(1 - ((float)price.Price / price.OriginalPrice)) * 100}% OFF"; break; case "AmountOff": ret.Banner = $"{price.OriginalPrice - price.Price} V-BUCKS OFF"; break; } ret.Type = ItemType.BUNDLE; //ret.ShortDescription.Text.SourceString = $"{items.Length} ITEM BUNDLE"; // TODO: fix this please lmao break; case "StaticPrice": default: ret.Price = new StaticPrice(entry.Prices[0].FinalPrice); break; } return(ret); }
public Pandora Product(string url) { try { var link = @url; HtmlWeb web = new HtmlWeb(); HtmlDocument htmlDocument = web.Load(link); if (htmlDocument.DocumentNode.SelectSingleNode("//img[@src='/images/hata.png']") != null) { Error = "Sayfa bulunamadı"; return(this); } var BookNameNode = htmlDocument.DocumentNode.SelectSingleNode(".//div[@id='urun-detay']/h1"); if (BookNameNode != null) { Name = BookNameNode.InnerText; } else { Error = "Kitap adına ulaşılamadı"; return(this); } /// <summary> /// indirimli üründe iki tip geri dönüş var: strong[@class='indirimliFiyat'] ve span[@class='eskiFiyat'] /// indirimsiz üründe bir tip geri dönüş var strong[@class='indirimliFiyat'] (ürün indirimli olmasa bile): strong[@class='indirimliFiyat'] buradan geri dönüş alıyoruz. /// /// /// Durum 1: Sayfa'da iki tane fiyat varsa (ürün indirimli ise) /// DiscountedPrice'a indirimli(strong[@class='indirimliFiyat']), /// NormalPrice'a indirimsiz(span[@class='eskiFiyat']) halini al /// /// Durum 2: Sayfa'da bir tane fiyat varsa (Ürün indirimsiz ise) /// NormalPrice'a fiyatı(strong[@class='indirimliFiyat']) al /// /// Durum 3: zaten açık /// </summary> var indirimliFiyatHtmlNode = htmlDocument.DocumentNode.SelectSingleNode(".//ul[@class='borderedPhone']/li/strong[@class='indirimliFiyat']"); var eskiFiyatHtmlNode = htmlDocument.DocumentNode.SelectSingleNode(".//ul[@class='borderedPhone']/li/span[@class='eskiFiyat']"); if (indirimliFiyatHtmlNode != null && eskiFiyatHtmlNode != null) { DiscountedPrice = indirimliFiyatHtmlNode.InnerText; NormalPrice = eskiFiyatHtmlNode.InnerText; DiscountedPrice = DiscountedPrice.Replace(" ", "").Replace("\r", "").Replace("\n", "").Replace(",", ".").Replace("TL", ""); NormalPrice = NormalPrice.Replace(" ", "").Replace("\r", "").Replace("\n", "").Replace(",", ".").Replace("TL", ""); } else if (indirimliFiyatHtmlNode != null) { NormalPrice = indirimliFiyatHtmlNode.InnerText; NormalPrice = NormalPrice.Replace(" ", "").Replace("\r", "").Replace("\n", "").Replace(",", ".").Replace("TL", ""); } else { Error = "Kitabın fiyatına ulaşılamadı"; return(this); } var PictureNode = htmlDocument.DocumentNode.SelectSingleNode(".//div[@class='coverWrapper posRel']/img"); if (PictureNode != null) { Picture = "https://www.pandora.com.tr" + PictureNode.Attributes["src"].Value; } else { Picture = ""; } Link = url; return(SelectPrice(this)); } catch { Error = "Beklenmedik bir problem ile karşılaştık"; return(this); } }