|
本帖最后由 xiangbo80 于 2024-4-18 23:24 编辑
本程序仅适合湖南电信IPTV环境下使用,自动提取组播资源并生成M3U列表格式,自动生成适配的XML格式EPG节目单。
重点:如果你的网络环境无法PING通10.255.0.110,则该贴对你暂无帮助,因不同的路由器或交换机对组播协议支持程度都不同,请自行解决网络环境的问题。
iptv.php:
- <?php
- header('Content-Type: audio/x-mpegurl');
- header('Content-Disposition: attachment; filename="playlist.m3u"');
- $url = 'http://10.255.0.110/mgtv_hndx/EPGV2/GetChannelList?OutputType=json&Version=HNDX.0.0_Release_HW_4K&CategoryId=1000&MediaAssetsId=live';
- $jsonData = file_get_contents($url);
- $data = json_decode($jsonData, true);
- if (json_last_error() !== JSON_ERROR_NONE) {
- die('JSON解析错误:' . json_last_error_msg());
- }
- if ($data["result"]["reason"] !== "OK") {
- die('JSON解析错误:' . json_last_error_msg());
- }
- echo "#EXTM3U\n";
- $iptvlist = $data["l"]["il"];
- foreach ($iptvlist as $item) {
- echo '#EXTINF:-1,tvg-id="'.$item["id"].'" tvg-name="'.$item["name"].'" tvg-logo="'.$item["img_h"].'"'."\n";
- echo $item["arg_list"]["c_playurl_live_mutlicast"]. "\n";
- //echo str_replace("rtp://","http://192.168.123.1:4000/rtp/", $item["arg_list"]["c_playurl_live_mutlicast"]). "\n";
- }
- ?>
复制代码 参数说明:
CategoryId分组编号可通过以下网址获取:http://10.255.0.110/mgtv_hndx/MA ... &MediaAssetsId=live
程序默认使用RTP或UDP组播源,如果你有搭建UDPROX代理请注释掉第18行,启用第19行并修改相关代理服务器地址,请根据你获取到的组播地址是RTP还是UDP协议并修改相关代码。
注释第2行将不生成M3U文件,可直接调用本程序URL。
epg.php:
- <?php
- $url = 'http://10.255.0.110/mgtv_hndx/EPGV2/GetChannelList?OutputType=json&Version=YYS.4.5.19.266.2.HNDX.0.0_Release_HW_4K&CategoryId=1000&MediaAssetsId=live';
- $jsonData = file_get_contents($url);
- $data = json_decode($jsonData, true);
- $xml = new SimpleXMLElement('<?xml version="1.0"?><tv></tv>');
- $xml->addAttribute("generator-info-name", "湖南电信IPTV-EPG");
- $iptvlist = $data["l"]["il"];
- foreach ($iptvlist as $item) {
- $channl=$xml->addChild("channel");
- $channl->addAttribute("id", $item["name"]);
- $channl->addChild("display-name", $item["name"]);
- $url2 = "http://10.255.0.110/mgtv_hndx/BasicIndex/GetPlaybill?AfterDay=3&TimeZone=8&OutputType=json&Version=YYS.4.5.19.266.2.HNDX.0.0_Release_HW_4K&VideoType=1&Mode=relative&VideoId=".$item["id"]."&BeforeDay=0";
- $menudata = file_get_contents($url2);
- $menulist = json_decode($menudata, true);
- foreach ($menulist["day"] as $item1) {
- foreach ($item1["item"] as $v) {
- $v["start"]=$item1["day"].$v["begin"];
- $v["stop"]=$v["start"]+$v["time_len"];
- $programme=$xml->addChild("programme");
- $programme->addAttribute("start", $v["start"]." +0800");
- $programme->addAttribute("stop", $v["stop"]." +0800");
- $programme->addAttribute("channel", $item["name"]);
- $programme->addChild("title", $v["text"]);
- }
- }
- }
- header("Content-type: application/xml");
- echo $xml->asXML();
- ?>
复制代码 参数说明:
AfterDay表示查看几天后的节目单。
BeforeDay表示查看几天前的节目单,默认为0,这个只有看回放才有用。
CategoryId使用默认的1000就行,已经适配了所有分组节目。
|
评分
-
查看全部评分
|