找回密码
 立即注册
搜索
查看: 297|回复: 15

求大佬分享四川几个省台的PHP

 火.. [复制链接]

14

主题

97

回帖

127

积分

注册会员

积分
127
发表于 2025-11-10 16:29:43 | 显示全部楼层 |阅读模式

求这几个台的PHP 谢谢

四川卫视  

四川广播电视台妇女儿童频道  

四川广播电视台公共频道   

四川广播电视台新闻频道   

四川广播电视台影视文艺频道

四川经济频道


0

主题

13

回帖

32

积分

新手上路

积分
32
发表于 2025-11-10 20:16:25 | 显示全部楼层
我也正在弄这几个台  还没起色...

1

主题

28

回帖

107

积分

注册会员

积分
107
发表于 2025-11-10 21:43:14 | 显示全部楼层
<?php
/*
四川卫视,sc.php?id=1
四川新闻,sc.php?id=2
四川经济,sc.php?id=3
四川文化旅游,sc.php?id=4
四川影视文艺,sc.php?id=5
四川妇女儿童,sc.php?id=6
四川星空购物,sc.php?id=7
四川乡村,sc.php?id=8
康巴卫视,sc.php?id=9
四川卫视4K,sc.php?id=10
*/

//https://www.sctv.com/watchTV
//https://iptv.cc/forum.php?mod=viewthread&tid=5856&highlight=%E5%9B%9B%E5%B7%9D
//https://www.utao.tv/
//https://bgithub.xyz/VonChange/utao/releases

if (need_m3u8($id, $ts_url)) {
    $u = get_m3u8_url($id);
    $c = send_request($u, $ct);
    $c = replace_ts_urls($u, $c);
} else {
    $c = send_request($ts_url, $ct);
    if ($ct == 'application/vnd.apple.mpegurl')
        $c = replace_ts_urls($ts_url, $c);
}
echo_content($ct, $c);



function need_m3u8(&$id, &$ts_url)
{
    $q = $_SERVER['QUERY_STRING'];
    $r = stripos($q, 'id=') === 0;
    if ($r)
        $id = $_GET['id'];
    else
        $ts_url = $q;
    return $r;
}

function get_m3u8_url($id)
{
    $u = 'http://api.vonchange.com/utao/sctv?tag='.$id;
    $r = file_get_contents($u);
    return $r;
}

function send_request($url, &$content_type)
{
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_REFERER, 'https://www.sctv.com/');
    $ua = 'Mozilla/5.0 (Linux; U; Android 8.1.0; zh-cn; BLA-AL00 Build/HUAWEIBLA-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/8.9 Mobile Safari/537.36';
    curl_setopt($ch, CURLOPT_USERAGENT, $ua);
    $res = curl_exec($ch);
    $content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
    curl_close($ch);
    return $res;
}

function replace_ts_urls($m3u8_url, $m3u8_content)
{
    //$m3u8_content = ltrim($m3u8_content, "\xEF\xBB\xBF");
    $dest_ts_path = dirname($m3u8_url)."/";
    $protocol = !empty($_SERVER['HTTPS']) ? 'https' : 'http';
    $self_part = "$protocol://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

    $s = 'URI="';
    if (strpos($m3u8_content, $s) !== false)
        $m3u8_content = str_replace($s, $s.$self_part.'?'.$dest_ts_path, $m3u8_content);

    return preg_replace_callback("/^((?!#).+)$/im",
        function ($matches) use ($self_part, $dest_ts_path) {
            if (!is_absolute_url($matches[1]))
                $ts = $dest_ts_path.$matches[1];
            else
                $ts = $matches[1];
            return "$self_part?$ts";
        },
        $m3u8_content
    );
}

function is_absolute_url($url) {
    return stripos($url, 'http:') === 0 || stripos($url, 'https:') === 0;
}

function echo_content($content_type, $content)
{
    header("Access-Control-Allow-Origin: *");
    header("Content-Type: $content_type");
    echo $content;
}

14

主题

97

回帖

127

积分

注册会员

积分
127
 楼主| 发表于 2025-11-11 08:04:02 | 显示全部楼层

0

主题

40

回帖

104

积分

注册会员

积分
104
发表于 2025-11-11 08:26:26 | 显示全部楼层

zhailingjiang 发表于 2025-11-10 21:43

太感谢了

0

主题

41

回帖

81

积分

注册会员

积分
81
发表于 2025-11-11 08:55:27 来自手机 | 显示全部楼层
zhailingjiang 发表于 2025-11-10 21:43

谢谢大佬

14

主题

97

回帖

127

积分

注册会员

积分
127
 楼主| 发表于 2025-11-11 11:56:14 | 显示全部楼层
myhb 发表于 2025-11-10 20:16
我也正在弄这几个台  还没起色...

等你好消息,到时分享一下

1

主题

19

回帖

25

积分

新手上路

积分
25
发表于 2025-11-11 13:31:00 | 显示全部楼层
能用了吗?

1

主题

19

回帖

25

积分

新手上路

积分
25
发表于 2025-11-11 13:52:27 | 显示全部楼层

已经测试,可以使用。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

14

主题

97

回帖

127

积分

注册会员

积分
127
 楼主| 发表于 2025-11-11 14:14:42 | 显示全部楼层
jankxia 发表于 2025-11-11 13:52
已经测试,可以使用。

请问下播放地址是怎样生成?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|直播源论坛