Commit 543fa9be authored by David Morley's avatar David Morley

use curl error to validate. check title and meta desc also in language test

parent 38922563
......@@ -98,7 +98,7 @@ foreach ($pods as $pod) {
// Default link to fetch node info.
$nodeinfo_url = "https://{$domain}/nodeinfo/1.0";
if ($nodeinfo_meta['body'] !== false) {
if (!isset($nodeinfo_meta['error'])) {
$info = json_decode($nodeinfo_meta['body'], true);
$nodeinfo_url = max($info['links'])['href'];
}
......@@ -254,7 +254,7 @@ foreach ($pods as $pod) {
if (!$language_snippet) {
$detectedlanguage = null;
--$score;
} elseif (Carbon::now()->hour === 12) {
} elseif (Carbon::now()->hour === 12 || $debug) {
$detectedlanguage = detectWebsiteLanguageFromSnippet($language_snippet);
}
......@@ -500,6 +500,15 @@ function getWebsiteLanguageSnippetFromUrl(string $url): ?string
}
}
}
$hs .= $d->getElementsByTagName('title')->item(0)->textContent . ' ';
$metas = $d->getElementsByTagName('meta');
foreach ($metas as $meta) {
if (strtolower($meta->getAttribute('name')) == 'description') {
$hs .= $meta->getAttribute('value');
}
}
return $hs;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment