]> git.mxchange.org Git - friendica.git/commitdiff
Improved profile probing for pump.io
authorMichael <heluecht@pirati.ca>
Tue, 13 Feb 2018 05:54:09 +0000 (05:54 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 13 Feb 2018 05:54:09 +0000 (05:54 +0000)
src/Network/Probe.php

index 1c2da38634d3f8730fb0ca9dc957cd6e42a61e4b..0f9de79abd975e3da0d17198a5894be6a39ead92 100644 (file)
@@ -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));
+                       }
+               }
+
+               $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;
                }
 
-               $avatar = $xpath->query("//img[@class='img-rounded media-object']")->item(0);
+               $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;
        }