Skip to content

Commit 85fe282

Browse files
cursor bugfix
1 parent 15e8422 commit 85fe282

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

www/index.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,14 +510,31 @@ function sponsor_segments(array $args): void
510510
{
511511
global $main;
512512

513+
// Validate required parameter
513514
if (empty($args['item_id'])) {
514515
$main->setResponseCode(404);
516+
header('Content-Type: application/json');
515517
echo json_encode(['error' => 'missing item_id']);
516518
return;
517519
}
518520

521+
// Retrieve the requested item and ensure it exists
519522
$item = $main->getState()->getFeedItem(intval($args['item_id']));
520-
$feed = $main->getState()->getFeed(intval($item['feed_id']));
523+
if (empty($item)) {
524+
$main->setResponseCode(404);
525+
header('Content-Type: application/json');
526+
echo json_encode(['error' => 'item not found']);
527+
return;
528+
}
529+
530+
// Retrieve the feed associated with the item and ensure it exists
531+
$feed = $main->getState()->getFeed(intval($item['feed_id'] ?? 0));
532+
if (empty($feed)) {
533+
$main->setResponseCode(404);
534+
header('Content-Type: application/json');
535+
echo json_encode(['error' => 'feed not found']);
536+
return;
537+
}
521538

522539
// Compose search query – podcast name + episode title.
523540
$query = ($feed['name'] ?? '') . ' ' . ($item['name'] ?? '');

0 commit comments

Comments
 (0)