diff --git a/bridges/FallGuysBridge.php b/bridges/FallGuysBridge.php
index 1e527484..46411f33 100644
--- a/bridges/FallGuysBridge.php
+++ b/bridges/FallGuysBridge.php
@@ -37,13 +37,14 @@ class FallGuysBridge extends BridgeAbstract
public function collectData()
{
- $html = getSimpleHTMLDOM(self::getURI());
+ $newsData = self::requestJsonData(self::getURI(), false);
- $data = json_decode($html->find('#__NEXT_DATA__', 0)->innertext);
+ foreach ($newsData->props->pageProps->newsList as $newsItem) {
+ $newsItemUrl = self::getURI() . '/' . $newsItem->slug;
+ $newsItemTitle = $newsItem->header->title;
- foreach ($data->props->pageProps->newsList as $newsItem) {
$headerDescription = property_exists($newsItem->header, 'description') ? $newsItem->header->description : '';
- $headerImage = $newsItem->header->image->src;
+ $headerImage = $newsItem->newsLandingConfig->options[0]->image->src->url;
$contentImages = [$headerImage];
@@ -52,67 +53,79 @@ class FallGuysBridge extends BridgeAbstract

HTML;
- foreach ($newsItem->content->items as $contentItem) {
- if (property_exists($contentItem, 'articleCopy')) {
- if (property_exists($contentItem->articleCopy, 'title')) {
- $title = $contentItem->articleCopy->title;
+ try {
+ $newsItemData = self::requestJsonData($newsItemUrl, true);
+ } catch (\Exception $e) {
+ $this->logger->error(sprintf('Failed to request data for news item "%s" (%s)', $newsItemTitle, $newsItemUrl), ['e' => $e]);
+ $newsItemData = null;
+ }
+ if (!$newsItemData) {
+ $this->logger->error(sprintf('Failed to parse json data for news item "%s" (%s)', $newsItemTitle, $newsItemUrl));
+ } else {
+ foreach ($newsItemData->props->pageProps->pageData->content->items as $contentItem) {
+ if (property_exists($contentItem, 'articleCopy')) {
+ if (property_exists($contentItem->articleCopy, 'title')) {
+ $title = $contentItem->articleCopy->title;
+
+ $content .= <<{$title}
+ HTML;
+ }
+
+ $text = $contentItem->articleCopy->copy;
$content .= <<{$title}
+ {$text}
HTML;
- }
+ } elseif (property_exists($contentItem, 'articleImage')) {
+ $image = $contentItem->articleImage->imageSrc;
- $text = $contentItem->articleCopy->copy;
+ if ($image != $headerImage) {
+ $contentImages[] = $image;
- $content .= <<{$text}
- HTML;
- } elseif (property_exists($contentItem, 'articleImage')) {
- $image = $contentItem->articleImage->imageSrc;
+ $content .= <<
+ HTML;
+ }
+ } elseif (property_exists($contentItem, 'embeddedVideo')) {
+ $mediaOptions = $contentItem->embeddedVideo->mediaOptions;
+ $mainContentOptions = $contentItem->embeddedVideo->mainContentOptions;
- if ($image != $headerImage) {
- $contentImages[] = $image;
+ if (count($mediaOptions) == count($mainContentOptions)) {
+ for ($i = 0; $i < count($mediaOptions); $i++) {
+ if (property_exists($mediaOptions[$i], 'youtubeVideo')) {
+ $videoUrl = 'https://youtu.be/' . $mediaOptions[$i]->youtubeVideo->contentId;
+ $image = $mainContentOptions[$i]->image->src ?? '';
- $content .= <<
- HTML;
- }
- } elseif (property_exists($contentItem, 'embeddedVideo')) {
- $mediaOptions = $contentItem->embeddedVideo->mediaOptions;
- $mainContentOptions = $contentItem->embeddedVideo->mainContentOptions;
+ $content .= '';
- if (count($mediaOptions) == count($mainContentOptions)) {
- for ($i = 0; $i < count($mediaOptions); $i++) {
- if (property_exists($mediaOptions[$i], 'youtubeVideo')) {
- $videoUrl = 'https://youtu.be/' . $mediaOptions[$i]->youtubeVideo->contentId;
- $image = $mainContentOptions[$i]->image->src ?? '';
+ if ($image != $headerImage) {
+ $contentImages[] = $image;
- $content .= '
';
-
- if ($image != $headerImage) {
- $contentImages[] = $image;
+ $content .= <<
+ HTML;
+ }
$content .= <<
+ (Video: {$videoUrl})
HTML;
+
+ $content .= '
';
}
-
- $content .= <<(Video: {$videoUrl})
- HTML;
-
- $content .= '';
}
}
+ } else {
+ $this->logger->warning(sprintf('Unsupported content item in news item "%s" (%s)', $newsItemTitle, $newsItemUrl));
}
}
}
$item = [
- 'uid' => $newsItem->_id,
- 'uri' => self::getURI() . '/' . $newsItem->_slug,
- 'title' => $newsItem->_title,
- 'timestamp' => $newsItem->lastModified,
+ 'uid' => $newsItem->id,
+ 'uri' => $newsItemUrl,
+ 'title' => $newsItemTitle,
+ 'timestamp' => $newsItem->activeDate,
'content' => $content,
'enclosures' => $contentImages,
];
@@ -131,4 +144,12 @@ class FallGuysBridge extends BridgeAbstract
{
return self::BASE_URI . '/favicon.ico';
}
+
+ private function requestJsonData(string $url, bool $useCache)
+ {
+ $html = $useCache ? getSimpleHTMLDOMCached($url) : getSimpleHTMLDOM($url);
+ $jsonElement = $html->find('#__NEXT_DATA__', 0);
+ $json = $jsonElement ? $jsonElement->innertext : null;
+ return json_decode($json);
+ }
}