93 if (readStatus == 0 && root.size() > 0)
95 LOG_INFO <<
"Processing JSON Values...";
102 result->raceId = root[
"playable_race"][
"id"].get<
int>();
103 result->gender = root[
"gender"][
"name"].get<std::string>();
106 for (
const auto& customization : root[
"customizations"])
108 auto optionid = customization[
"option"][
"id"].get<
int>();
109 auto choiceid = customization[
"choice"][
"id"].get<
int>();
110 result->customizations.emplace_back(optionid, choiceid);
115 result->hasTransmogGear =
false;
116 for (
const auto& item : root[
"items"])
119 result->equipment[slot] = item[
"id"].get<
int>();
120 result->itemModifierIds[slot] = item[
"item_appearance_modifier_id"].get<
int>();
125 if (root[
"class"].get<int>() == 6)
132 if (root.contains(
"guild_crest") && !root[
"guild_crest"].empty())
134 const auto& guildTabard = root[
"guild_crest"];
135 result->tabardIcon = guildTabard[
"emblem"][
"id"].get<
int>();
136 result->iconColor = guildTabard[
"emblem"][
"color"][
"id"].get<
int>();
137 result->tabardBorder = guildTabard[
"border"][
"id"].get<
int>();
138 result->borderColor = guildTabard[
"border"][
"color"][
"id"].get<
int>();
139 result->background = guildTabard[
"background"][
"color"][
"id"].get<
int>();
141 result->customTabard =
true;
144 result->valid =
true;
148 LOG_ERROR <<
"Bad JSON Results:" << readStatus <<
"Root Size:" << root.size();
197 const auto& strUrl(url);
201 std::string charName;
204 auto splitString = [](
const std::string& s,
char delim) {
205 std::vector<std::string> tokens;
206 std::istringstream stream(s);
208 while (std::getline(stream, token, delim))
209 tokens.push_back(token);
214 if (strUrl.find(
"battle.net") != std::string::npos)
218 if ((strUrl.find(
"simple") == std::string::npos) &&
219 (strUrl.find(
"advanced") == std::string::npos))
221 LOG_ERROR <<
"Improperly Formatted URL. Lacks /simple and /advanced";
225 const auto strList = splitString(strUrl.substr(7),
'/');
227 auto dotPos = strList.at(0).find(
'.');
228 region = (dotPos != std::string::npos) ? strList.at(0).substr(0, dotPos) : strList.at(0);
229 realm = strList.at(strList.size() - 3);
230 auto qPos = strUrl.rfind(
'?');
231 charName = strList.at(strList.size() - 2);
232 if (qPos != std::string::npos)
233 charName = charName.substr(0, qPos - 1);
234 LOG_INFO <<
"Battle Net, CharName: " << charName <<
" Realm: " << realm <<
" Region: " << region;
236 else if ((strUrl.find(
"worldofwarcraft.com") != std::string::npos) || (url.find(
"blizzard.com") != std::string::npos))
243 const auto strList = splitString(strUrl.substr(8),
'/');
245 if (strList.size() > 5)
246 region = strList.at(3);
248 region = strList.at(1);
250 realm = strList.at(strList.size() - 2);
251 charName = strList.at(strList.size() - 1);
252 auto qPos = charName.rfind(
'?');
253 if (qPos != std::string::npos)
254 charName = charName.substr(0, qPos);
255 LOG_INFO <<
"WoW.com, CharName:" << charName <<
"Realm:" << realm <<
"Region:" << region;
258 if ((region ==
"fr-fr") || (region ==
"en-gb"))
260 else if (region ==
"en-us")
262 else if (region ==
"zh-tw")
264 else if (region ==
"ko-kr")
269 LOG_ERROR <<
"Improperly Formatted URL. The domain should be worldofwarcraft.com or blizzard.com";
273 LOG_INFO <<
"Loading Battle.Net Armory. Region:" << region
274 <<
", Realm:" << realm
275 <<
", Character:" << charName;
277 apiPage =
"https://wowmodelviewer.net/armory2.php?region=" + region +
"&realm=" + realm +
"&char=" + charName;
290 const auto& strUrl(url);
291 auto lastSlash = strUrl.rfind(
'/');
292 const auto itemNumber = (lastSlash != std::string::npos) ? strUrl.substr(lastSlash) : strUrl;
294 LOG_INFO <<
"Loading Battle.Net Armory. Item: " << itemNumber;
296 apiPage =
"https://wowmodelviewer.net/armory.php?item=" + itemNumber;
301 LOG_ERROR <<
"Invalid Import Type: " << type;
305 LOG_INFO <<
"Final API Page:" << apiPage;
309 result = nlohmann::json::parse(bts,
nullptr,
false);
310 if (result.is_discarded())