1
0
Fork 0

Some more added types

This commit is contained in:
Michael 2021-03-17 17:11:50 +00:00
parent da6b54925a
commit f11712cdc0

View file

@ -556,29 +556,70 @@ class ParseUrl
return $siteinfo; return $siteinfo;
} }
// Silently ignore some types that aren't processed
if (in_array($type, ['SiteNavigationElement', 'JobPosting', 'CreativeWork',
'WPHeader', 'WPSideBar', 'WPFooter', 'LegalService',
'ItemList', 'BreadcrumbList', 'Blog', 'Dataset', 'Product'])) {
return $siteinfo;
}
switch ($type) { switch ($type) {
case 'Article': case 'Article':
case 'AdvertiserContentArticle':
case 'NewsArticle': case 'NewsArticle':
case 'Report':
case 'SatiricalArticle':
case 'ScholarlyArticle': case 'ScholarlyArticle':
case 'SocialMediaPosting':
case 'TechArticle':
case 'ReportageNewsArticle': case 'ReportageNewsArticle':
case 'SocialMediaPosting': case 'SocialMediaPosting':
case 'LiveBlogPosting':
case 'BlogPosting': case 'BlogPosting':
case 'LiveBlogPosting':
case 'DiscussionForumPosting': case 'DiscussionForumPosting':
return self::parseJsonLdArticle($siteinfo, $jsonld); return self::parseJsonLdArticle($siteinfo, $jsonld);
case 'WebPage': case 'WebPage':
case 'AboutPage':
case 'CheckoutPage':
case 'CollectionPage': case 'CollectionPage':
case 'ContactPage':
case 'FAQPage':
case 'ItemPage':
case 'MedicalWebPage':
case 'ProfilePage':
case 'QAPage':
case 'RealEstateListing':
case 'SearchResultsPage':
case 'MediaGallery':
case 'ImageGallery': case 'ImageGallery':
case 'VideoGallery':
case 'RadioEpisode': case 'RadioEpisode':
case 'Event': case 'Event':
return self::parseJsonLdWebPage($siteinfo, $jsonld); return self::parseJsonLdWebPage($siteinfo, $jsonld);
case 'WebSite': case 'WebSite':
return self::parseJsonLdWebSite($siteinfo, $jsonld); return self::parseJsonLdWebSite($siteinfo, $jsonld);
case 'Organization': case 'Organization':
case 'NewsMediaOrganization': case 'Airline':
case 'Consortium':
case 'Corporation':
case 'EducationalOrganization':
case 'FundingScheme':
case 'GovernmentOrganization':
case 'LibrarySystem':
case 'LocalBusiness': case 'LocalBusiness':
case 'MedicalOrganization':
case 'NGO':
case 'NewsMediaOrganization':
case 'Project':
case 'SportsOrganization':
case 'WorkersUnion':
return self::parseJsonLdWebOrganization($siteinfo, $jsonld); return self::parseJsonLdWebOrganization($siteinfo, $jsonld);
case 'Person': case 'Person':
case 'Patient':
case 'PerformingGroup':
case 'DanceGroup';
case 'MusicGroup':
case 'TheaterGroup':
return self::parseJsonLdWebPerson($siteinfo, $jsonld); return self::parseJsonLdWebPerson($siteinfo, $jsonld);
case 'AudioObject': case 'AudioObject':
case 'Audio': case 'Audio':
@ -587,23 +628,8 @@ class ParseUrl
return self::parseJsonLdMediaObject($siteinfo, $jsonld, 'video'); return self::parseJsonLdMediaObject($siteinfo, $jsonld, 'video');
case 'ImageObject': case 'ImageObject':
return self::parseJsonLdMediaObject($siteinfo, $jsonld, 'images'); return self::parseJsonLdMediaObject($siteinfo, $jsonld, 'images');
case 'WPHeader':
case 'WPSideBar':
case 'WPFooter':
case 'LegalService':
case 'MusicGroup':
case 'ItemList':
case 'BreadcrumbList':
case 'Blog':
case 'Dataset':
case 'Product':
// quit silently
return $siteinfo;
default: default:
Logger::info('Unsupported or unknown type', ['type' => $type, 'url' => $siteinfo['url']]); Logger::info('Unknown type', ['type' => $type, 'url' => $siteinfo['url']]);
return $siteinfo; return $siteinfo;
} }
} }
@ -641,6 +667,10 @@ class ParseUrl
if (!empty($content) && is_string($content)) { if (!empty($content) && is_string($content)) {
$jsonldinfo['publisher_name'] = trim($content); $jsonldinfo['publisher_name'] = trim($content);
} }
$content = JsonLD::fetchElement($brand, 'url', '@type', 'brand');
if (!empty($content) && is_string($content)) {
$jsonldinfo['publisher_url'] = trim($content);
}
} }
} elseif (!empty($jsonld['publisher']) && is_string($jsonld['publisher'])) { } elseif (!empty($jsonld['publisher']) && is_string($jsonld['publisher'])) {
$jsonldinfo['publisher_name'] = trim($jsonld['publisher']); $jsonldinfo['publisher_name'] = trim($jsonld['publisher']);
@ -829,6 +859,11 @@ class ParseUrl
$jsonldinfo['publisher_description'] = trim($content); $jsonldinfo['publisher_description'] = trim($content);
} }
$content = JsonLD::fetchElement($jsonld, 'sameAs');
if (!empty($content) && is_string($content)) {
$jsonldinfo['publisher_url'] = trim($content);
}
$content = JsonLD::fetchElement($jsonld, 'url'); $content = JsonLD::fetchElement($jsonld, 'url');
if (!empty($content)) { if (!empty($content)) {
$jsonldinfo['publisher_url'] = trim($content); $jsonldinfo['publisher_url'] = trim($content);
@ -839,6 +874,16 @@ class ParseUrl
$jsonldinfo['publisher_img'] = trim($content); $jsonldinfo['publisher_img'] = trim($content);
} }
$content = JsonLD::fetchElement($jsonld, 'brand', 'name', '@type', 'Organization');
if (!empty($content)) {
$jsonldinfo['publisher_name'] = trim($content);
}
$content = JsonLD::fetchElement($jsonld, 'brand', 'url', '@type', 'Organization');
if (!empty($content)) {
$jsonldinfo['publisher_url'] = trim($content);
}
Logger::info('Fetched Organization information', ['url' => $siteinfo['url'], 'fetched' => $jsonldinfo]); Logger::info('Fetched Organization information', ['url' => $siteinfo['url'], 'fetched' => $jsonldinfo]);
return array_merge($siteinfo, $jsonldinfo); return array_merge($siteinfo, $jsonldinfo);
} }
@ -865,6 +910,11 @@ class ParseUrl
$jsonldinfo['author_description'] = trim($content); $jsonldinfo['author_description'] = trim($content);
} }
$content = JsonLD::fetchElement($jsonld, 'sameAs');
if (!empty($content) && is_string($content)) {
$jsonldinfo['author_url'] = trim($content);
}
$content = JsonLD::fetchElement($jsonld, 'url'); $content = JsonLD::fetchElement($jsonld, 'url');
if (!empty($content)) { if (!empty($content)) {
$jsonldinfo['author_url'] = trim($content); $jsonldinfo['author_url'] = trim($content);