![]() | |
BlazeTV podcast... The 10 most recent videos from Glenn Beck & BlazeTV | |
/s', $html, $m)) { die('ytInitialData not found. YouTube layout may have changed.'); } $json = $m[1]; $data = json_decode($json, true); if (json_last_error() !== JSON_ERROR_NONE) { die('Invalid JSON in ytInitialData.'); } // Find Videos tab $tabs = $data['contents']['twoColumnBrowseResultsRenderer']['tabs'] ?? []; $videosTab = null; foreach ($tabs as $tab) { if (isset($tab['tabRenderer']['title']) && $tab['tabRenderer']['title'] === 'Videos') { $videosTab = $tab['tabRenderer']; break; } } if (!$videosTab) { die('Videos tab not found.'); } $contents = $videosTab['content']['richGridRenderer']['contents'] ?? []; $videos = []; $count = 0; foreach ($contents as $item) { if ($count >= 12) break; // Skip non-video items (ads, continuations, etc.) if (!isset($item['richItemRenderer']['content']['videoRenderer'])) { continue; } $vr = $item['richItemRenderer']['content']['videoRenderer']; $videoId = $vr['videoId'] ?? ''; $title = $vr['title']['runs'][0]['text'] ?? 'No title'; $published = $vr['publishedTimeText']['simpleText'] ?? '—'; $views = $vr['viewCountText']['simpleText'] ?? '—'; $duration = $vr['lengthText']['simpleText'] ?? '—'; // Best thumbnail (usually last = highest res) $thumbs = $vr['thumbnail']['thumbnails'] ?? []; $thumbnail = !empty($thumbs) ? end($thumbs)['url'] : ''; // Try to get short description from channel page (rarely present, usually empty) $shortDescFromList = ''; if (isset($vr['descriptionSnippet']['runs'])) { foreach ($vr['descriptionSnippet']['runs'] as $run) { $shortDescFromList .= $run['text']; } } // Fetch full/short description from video page $description = $shortDescFromList; // fallback if ($videoId) { $videoPageHtml = fetchUrl("https://www.youtube.com/watch?v={$videoId}"); if ($videoPageHtml) { if (preg_match('/var ytInitialData\s*=\s*({.+?});\s*<\/script>/s', $videoPageHtml, $vm)) { $vdata = json_decode($vm[1], true); // Modern path (2025+) $descObj = $vdata['microformat']['playerMicroformatRenderer']['description'] ?? null; if ($descObj) { if (isset($descObj['simpleText'])) { $description = $descObj['simpleText']; } elseif (isset($descObj['runs'])) { $description = ''; foreach ($descObj['runs'] as $run) { $description .= $run['text']; } } } // Alternative path sometimes used if (!$description && isset($vdata['contents']['twoColumnWatchNextResults']['results']['results']['contents'][0]['videoPrimaryInfoRenderer'])) { // ... rarely has description here } } } } $embedUrl = "https://www.youtube.com/embed/{$videoId}"; $watchUrl = "https://www.youtube.com/watch?v={$videoId}"; $videos[] = [ 'id' => $videoId, 'title' => $title, 'thumbnail' => $thumbnail, 'description' => $description, 'short_desc' => $shortDescFromList ?: substr($description, 0, 120) . (strlen($description) > 120 ? '...' : ''), 'published' => $published, 'views' => $views, 'duration' => $duration, 'embed_url' => $embedUrl, 'watch_url' => $watchUrl, ]; $count++; } ?>
10 Most Recent BlazeTV Videos
= htmlspecialchars($v['title']) ?>
= nl2br(htmlspecialchars(substr($v['description'], 0, 220))) ?>
= strlen($v['description']) > 220 ? '...' : '' ?>
No description available
