diff --git a/bridges/CruncyrollBridge.php b/bridges/CruncyrollBridge.php
index 2001e7e4..7cff443a 100644
--- a/bridges/CruncyrollBridge.php
+++ b/bridges/CruncyrollBridge.php
@@ -1,26 +1,10 @@
[
@@ -41,12 +25,9 @@ class CrunchyrollBridge extends BridgeAbstract {
'required' => false,
'defaultValue' => 1,
],
- ]
+ ],
];
- /**
- * Collects data from the Crunchyroll API and formats it as an RSS feed.
- */
public function collectData() {
// Define API base URL
$apiBaseUrl = 'https://cr-news-api-service.prd.crunchyrollsvc.com/v1/en-US/stories/search';
@@ -56,7 +37,7 @@ class CrunchyrollBridge extends BridgeAbstract {
$pageSize = $this->getInput('page_size');
$page = $this->getInput('page');
- // Construct the API URL
+ // Construct the API URL with query parameters
$apiUrl = sprintf(
'%s?category=%s&page_size=%d&page=%d',
$apiBaseUrl,
@@ -96,15 +77,35 @@ class CrunchyrollBridge extends BridgeAbstract {
throw new Exception('Failed to decode JSON response: ' . json_last_error_msg());
}
+ // Map UUIDs to author names from the `rels` array
+ $authorMap = [];
+ foreach ($data['rels'] as $rel) {
+ if (isset($rel['uuid']) && isset($rel['content']['name'])) {
+ $authorMap[$rel['uuid']] = $rel['content']['name'];
+ }
+ }
+
// Process each story in the response
foreach ($data['stories'] as $story) {
$item = [];
+ // Find the author name(s) for the story
+ $authorNames = [];
+ if (!empty($story['content']['authors'])) {
+ foreach ($story['content']['authors'] as $authorUuid) {
+ if (isset($authorMap[$authorUuid])) {
+ $authorNames[] = $authorMap[$authorUuid];
+ }
+ }
+ }
+
+ // Set the `author` field to the resolved names or default to 'Unknown'
+ $item['author'] = implode(', ', $authorNames) ?: 'Unknown';
+
// Set the item properties
$item['uri'] = self::URI . '/' . $story['slug'];
$item['title'] = $story['content']['headline'];
$item['timestamp'] = strtotime($story['content']['article_date']);
- $item['author'] = 'Unknown'; // Author data can be added if available
$item['content'] = sprintf(
'
%s',
$story['content']['thumbnail']['filename'],