/**
* 双频道EPG节目表 - 纯PHP字符串版(无语法错误)
* 频道:AMC中文台 / AMC Y2K
* 日期:中文台动态8天 | Y2K固定2026-03-02~08(周一~周日)
*/
function amc_epg_shortcode($atts) {
// 基础配置
$xml_amc_cn = 'https://www.amccharts.com/amc_epg.xml';
$xml_amc_y2k = 'https://www.amccharts.com/amcy2kepg.xml';
$now_bj = time() + 8 * 3600; // 北京时间戳
$today_bj = date('Y-m-d', $now_bj);
$week_map = ['日', '一', '二', '三', '四', '五', '六'];
// 加载并解析XML的函数
function load_epg($url) {
$ctx = stream_context_create(['http' => ['timeout' => 10]]);
$str = @file_get_contents($url, false, $ctx);
if (!$str) return [];
libxml_use_internal_errors(true);
$xml = simplexml_load_string($str);
$data = [];
if ($xml) {
foreach ($xml->programme as $p) {
$ts1 = strtotime((string)$p['start']);
$ts2 = strtotime((string)$p['stop']);
$d = date('Y-m-d', $ts1 + 8*3600); // 转换为北京时间日期
$data[$d][] = [
'time' => date('H:i', $ts1 + 8*3600),
'title' => (string)$p->title,
'start' => $ts1 + 8*3600,
'stop' => $ts2 + 8*3600,
];
}
}
return $data;
}
// 加载两个频道的EPG数据
$epg_cn = load_epg($xml_amc_cn);
$epg_y2k = load_epg($xml_amc_y2k);
// 生成中文台的8天日期(昨天+今天+未来6天)
$days_cn = [];
for ($i = -1; $i <= 6; $i++) {
$days_cn[] = date('Y-m-d', strtotime("{$today_bj} +{$i} days"));
}
// Y2K频道固定日期映射(周一~周日)
$week_list = ['一','二','三','四','五','六','日'];
$fixed_map = [
'一' => '2026-03-02',
'二' => '2026-03-03',
'三' => '2026-03-04',
'四' => '2026-03-05',
'五' => '2026-03-06',
'六' => '2026-03-07',
'日' => '2026-03-08',
];
// ========== 拼接HTML(纯字符串,无语法错误) ==========
$html = '';
// 容器样式
$html .= '
';
// 1. 频道切换标签
$html .= '
';
$html .= '';
$html .= '';
$html .= '
';
// 2. AMC中文台内容(默认显示)
$html .= '
';
// 中文台日期标签
$html .= '
';
foreach ($days_cn as $i => $d) {
$week_day = $week_map[date('w', strtotime($d))];
$active_style = ($i == 1) ? 'background:#0eb200;color:white;' : 'background:#f5f5f5;';
$html .= '';
}
$html .= '
';
// 中文台日期内容
foreach ($days_cn as $i => $d) {
$display = ($i == 1) ? 'block' : 'none';
$html .= '
';
$html .= '
' . $d . '
';
$html .= '
';
// 节目列表
$items = $epg_cn[$d] ?? [];
if (empty($items)) {
$html .= '- 暂无节目
';
} else {
foreach ($items as $item) {
$past = ($now_bj >= $item['stop']);
$curr = ($now_bj >= $item['start'] && $now_bj < $item['stop']);
// 样式拼接
$li_style = 'padding:8px 0;display:flex;border-bottom:1px dashed #eee;';
if ($past) $li_style .= 'color:#999;opacity:0.6;';
if ($curr) $li_style .= 'background:#f1f1f1;padding:8px 10px;';
$time_color = $past ? '#999' : '#0eb200';
$html .= '- ';
$html .= '' . $item['time'] . '';
$html .= '' . $item['title'] . '';
if ($curr) {
$html .= 'Now';
}
$html .= '
';
}
}
$html .= '
';
}
$html .= '
'; // 关闭中文台容器
// 3. AMC Y2K内容(默认隐藏)
$html .= '
';
// Y2K日期标签
$html .= '
';
foreach ($week_list as $i => $w) {
$d = $fixed_map[$w];
$active_style = ($i == 0) ? 'background:#0eb200;color:white;' : 'background:#f5f5f5;';
$html .= '';
}
$html .= '
';
// Y2K日期内容
foreach ($week_list as $i => $w) {
$d = $fixed_map[$w];
$display = ($i == 0) ? 'block' : 'none';
$html .= '
';
$html .= '
' . $d . '
';
$html .= '
';
// 节目列表
$items = $epg_y2k[$d] ?? [];
if (empty($items)) {
$html .= '- 暂无节目
';
} else {
foreach ($items as $item) {
$past = ($now_bj >= $item['stop']);
$curr = ($now_bj >= $item['start'] && $now_bj < $item['stop']);
$li_style = 'padding:8px 0;display:flex;border-bottom:1px dashed #eee;';
if ($past) $li_style .= 'color:#999;opacity:0.6;';
if ($curr) $li_style .= 'background:#f1f1f1;padding:8px 10px;';
$time_color = $past ? '#999' : '#0eb200';
$html .= '- ';
$html .= '' . $item['time'] . '';
$html .= '' . $item['title'] . '';
if ($curr) {
$html .= 'Now';
}
$html .= '
';
}
}
$html .= '
';
}
$html .= '
'; // 关闭Y2K容器
// 4. 切换逻辑JS(内嵌)
$html .= '';
// 关闭容器
$html .= '
';
// 返回最终HTML
return $html;
}
add_shortcode('amc_epg', 'amc_epg_shortcode');
2021 AMC馬拉松跨年演唱會 – AMC音乐榜
2021 AMC馬拉松跨年演唱會
2020年12月27日 /
KTVS
/ 0 Comments
又到年終時,AMC 馬拉松跨年演唱會即將於12/31晚間6點準時登場,鑑於新冠肺炎疫情風險仍在,有別於往年安排,今年AMC馬拉松跨年演唱會將設立多個分會場,採以直播+連線+錄播的方式陪您一同倒數迎接新年。
AMC中文台/AMC Live/AMC中國台/KTVS中文台/國語娛樂台MeTV以及SMART全系列頻道屆時將全程同步直播。讓AMC與您一同迎接新年!!