<?php
if (!function_exists('ugfx_fetch_nowplaying_title')) {
function ugfx_fetch_nowplaying_title(): string {
    require_once __DIR__ . '/stream_lib.php';
    $source = ugfx_pick_preferred_source(ugfx_parse_icecast_data(ugfx_fetch_icecast_xml())['sources'] ?? []);
    $title = trim((string)($source['title'] ?? ''));
    return $title !== '' ? $title : 'Underground FX Live';
}
}
