/// <summary> /// Recursively build an item craft tree /// </summary> /// <param name="iItem"></param> public static FFXIVItem RecBuildCraftingTree(System.Windows.Forms.TextBox iLogBox, string iItemID, int quantity = 1) { if (null == iItemID) { return(null); } //https://www.garlandtools.org/db/doc/item/en/3/26498.json FFXIVItem item = null; CookieCollection iCookies = new CookieCollection(); CookieCollection oCookies = new CookieCollection(); HttpStatusCode oCode = HttpStatusCode.NotFound; string searchResultContent = Service_Misc.GetContentFromRequest("GET https://www.garlandtools.org/db/doc/item/en/3/" + iItemID + ".json HTTP/1.1|Host: www.garlandtools.org|Connection: keep-alive|Pragma: no-cache|Cache-Control: no-cache|Upgrade-Insecure-Requests: 1|User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36|Sec-Fetch-Mode: navigate|Sec-Fetch-User: ?1|Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3|Sec-Fetch-Site: cross-site|Accept-Encoding: gzip, deflate|Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7|", iCookies, ref oCookies, ref oCode); try { string logName2 = Path.Combine(Service_Misc.GetExecutionPath(), "Searchlog.log"); File.WriteAllText(logName2, searchResultContent); } catch { } string logName = Path.Combine(Service_Misc.GetExecutionPath(), "GeneralDataBase.log"); string dataResultContent = ""; if (File.Exists(logName)) { dataResultContent = File.ReadAllText(logName); } if (dataResultContent == "") { dataResultContent = Service_Misc.RemoveIllegalCharacters(Service_Misc.GetContentFromRequest("GET http://garlandtools.org/db/doc/core/en/3/data.json HTTP/1.1|Host: garlandtools.org|Connection: keep-alive|Pragma: no-cache|Cache-Control: no-cache|Accept: application/json, text/javascript, */*; q=0.01|X-Requested-With: XMLHttpRequest|User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36|Referer: http://garlandtools.org/db/|Accept-Encoding: gzip, deflate|Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7|", iCookies, ref oCookies, ref oCode)); try { File.WriteAllText(logName, dataResultContent); } catch { } } try { JToken mainToken = JObject.Parse(searchResultContent); if (null == mainToken) { return(item); } JToken dataToken = JObject.Parse(dataResultContent); if (null == dataToken) { return(item); } JToken itemToken = mainToken["item"]; if (null == itemToken) { return(item); } JToken mainIngredientToken = mainToken["ingredients"]; List <JToken> allIngredientsToken = new List <JToken>(); List <string> allIngredientsIDs = new List <string>(); if (null != mainIngredientToken) { //Listing ingredients nodes and ID foreach (JToken ingredientToken in mainIngredientToken.Children()) { if (null == ingredientToken) { continue; } string ID = ingredientToken["id"].Value <string>(); allIngredientsIDs.Add(ID); allIngredientsToken.Add(ingredientToken); } } item = CreateItemFromNode(iLogBox, iCookies, ref oCookies, ref oCode, itemToken, dataToken, allIngredientsToken, allIngredientsIDs); if (null != item) { item.Quantity = quantity; } } catch (Exception exc) { Service_Misc.LogText(iLogBox, "Ouch I failed !"); Service_Misc.LogText(iLogBox, exc.Message); } if (null != item) { Service_Misc.LogText(iLogBox, "Got this item ! " + item); } return(item); }
/// <summary> /// Retrieve all gathering nodes from an item /// </summary> /// <param name="iItemID"></param> /// <returns></returns> public static List <FFXIVGatheringNode> GetGatheringNodesFromItem(string iItemID) { List <FFXIVGatheringNode> result = new List <FFXIVGatheringNode>(); if (null == iItemID) { return(result); } //https://www.garlandtools.org/db/doc/item/en/3/26498.json CookieCollection iCookies = new CookieCollection(); CookieCollection oCookies = new CookieCollection(); HttpStatusCode oCode = HttpStatusCode.NotFound; string searchResultContent = Service_Misc.GetContentFromRequest("GET https://www.garlandtools.org/db/doc/item/en/3/" + iItemID + ".json HTTP/1.1|Host: www.garlandtools.org|Connection: keep-alive|Pragma: no-cache|Cache-Control: no-cache|Upgrade-Insecure-Requests: 1|User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36|Sec-Fetch-Mode: navigate|Sec-Fetch-User: ?1|Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3|Sec-Fetch-Site: cross-site|Accept-Encoding: gzip, deflate|Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7|", iCookies, ref oCookies, ref oCode); try { string logName2 = Path.Combine(Service_Misc.GetExecutionPath(), "Searchlog.log"); File.WriteAllText(logName2, searchResultContent); } catch { } string logName = Path.Combine(Service_Misc.GetExecutionPath(), "GeneralDataBase.log"); string dataResultContent = ""; if (File.Exists(logName)) { dataResultContent = File.ReadAllText(logName); } if (dataResultContent == "") { dataResultContent = Service_Misc.RemoveIllegalCharacters(Service_Misc.GetContentFromRequest("GET http://garlandtools.org/db/doc/core/en/3/data.json HTTP/1.1|Host: garlandtools.org|Connection: keep-alive|Pragma: no-cache|Cache-Control: no-cache|Accept: application/json, text/javascript, */*; q=0.01|X-Requested-With: XMLHttpRequest|User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36|Referer: http://garlandtools.org/db/|Accept-Encoding: gzip, deflate|Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7|", iCookies, ref oCookies, ref oCode)); try { File.WriteAllText(logName, dataResultContent); } catch { } } try { JToken mainToken = JObject.Parse(searchResultContent); if (null == mainToken) { return(result); } JToken dataToken = JObject.Parse(dataResultContent); if (null == dataToken) { return(result); } JToken itemToken = mainToken["item"]; if (null == itemToken) { return(result); } JToken nodeToken = itemToken["nodes"]; if (null != nodeToken) { return(ReadGatheredNodes(iCookies, ref oCookies, ref oCode, dataToken, itemToken, nodeToken)); } } catch { } return(result); }