From 7df60ae6347e42e8b247aa8732df39ac5c50fb6e Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 13 Feb 2018 05:54:09 +0000 Subject: [PATCH] Improved profile probing for pump.io --- src/Network/Probe.php | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/Network/Probe.php b/src/Network/Probe.php index 1c2da3863..0f9de79ab 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -1332,14 +1332,33 @@ class Probe $data = []; - // This is ugly - but pump.io doesn't seem to know a better way for it - $data["name"] = trim($xpath->query("//h1[@class='media-header']")->item(0)->nodeValue); - $pos = strpos($data["name"], chr(10)); - if ($pos) { - $data["name"] = trim(substr($data["name"], 0, $pos)); + $data["name"] = $xpath->query("//span[contains(@class, 'p-name')]")->item(0)->nodeValue; + + if ($data["name"] == '') { + // This is ugly - but pump.io doesn't seem to know a better way for it + $data["name"] = trim($xpath->query("//h1[@class='media-header']")->item(0)->nodeValue); + $pos = strpos($data["name"], chr(10)); + if ($pos) { + $data["name"] = trim(substr($data["name"], 0, $pos)); + } } - $avatar = $xpath->query("//img[@class='img-rounded media-object']")->item(0); + $data["location"] = $xpath->query("//p[contains(@class, 'p-locality')]")->item(0)->nodeValue; + + if ($data["location"] == '') { + $data["location"] = $xpath->query("//p[contains(@class, 'location')]")->item(0)->nodeValue; + } + + $data["about"] = $xpath->query("//p[contains(@class, 'p-note')]")->item(0)->nodeValue; + + if ($data["about"] == '') { + $data["about"] = $xpath->query("//p[contains(@class, 'summary')]")->item(0)->nodeValue; + } + + $avatar = $xpath->query("//img[contains(@class, 'u-photo')]")->item(0); + if (!$avatar) { + $avatar = $xpath->query("//img[@class='img-rounded media-object']")->item(0); + } if ($avatar) { foreach ($avatar->attributes as $attribute) { if ($attribute->name == "src") { @@ -1348,9 +1367,6 @@ class Probe } } - $data["location"] = $xpath->query("//p[@class='location']")->item(0)->nodeValue; - $data["about"] = $xpath->query("//p[@class='summary']")->item(0)->nodeValue; - return $data; }