找回密码
 立即注册
搜索
查看: 201|回复: 3

重温经典

[复制链接]

6

主题

68

回帖

80

积分

彩电迷

积分
80
发表于 2025-11-26 22:01:15 | 显示全部楼层 |阅读模式
<?php

date_default_timezone_set('Asia/Shanghai');

$cacheFile = __DIR__ . '/cwjdHD.txt';

function getCommonHeaders(): array
{
    $deviceId = md5(time());
    return [
        'charset: UTF-8',
        'channelId: cbn',
        'deviceType: 2048',
        'releaseVersion: 2.0.3',
        'releaseVersionCode: 203',
        'uId: ',
        'os: Android',
        "deviceId: {$deviceId}",
        'API-VERSION: 2',
        'orgCode: ',
        'token: ',
        'isGd: ',
        'User-Agent: okhttp/3.14.9',
        'Accept: */*',
        'Connection: keep-alive',
    ];
}

if (file_exists($cacheFile) && (time() - filemtime($cacheFile) < 600)) {
    $cachedUrl = trim(file_get_contents($cacheFile));
    header('Location: ' . $cachedUrl);
    exit;
}

function generateSign(string $input, bool $flag): string
{
    $ts = time();
    srand($ts);

    $charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
    $maxIdx = strlen($charset) - 1;

    $randLen = rand(0, 7);
    if ($randLen < 4) {
        $randLen += 4;
    }

    $randStr = '';
    for ($i = 0; $i < $randLen; $i++) {
        $randStr .= $charset[rand(0, $maxIdx)];
    }

    $suffix = $flag
        ? '01234ibcp9'
        : '0123456789';

    $s1 = sprintf('%s-%d-%s-%s', $input, $ts, $randStr, $suffix);
    $hexMd5 = md5($s1);

    return sprintf('%d-%s-%s', $ts, $randStr, $hexMd5);
}

function httpRequest($url, $method, $payload, $headers)
{
    $ch = curl_init();
    curl_setopt_array($ch, [
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_SSL_VERIFYHOST => false,
        CURLOPT_TIMEOUT => 10,
        CURLOPT_CONNECTTIMEOUT => 5,
    ]);

    if (strtoupper($method) === 'POST') {
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
        $headers[] = 'Content-Type: application/json';
    }

    if (!empty($headers)) {
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    }

    $resp = curl_exec($ch);
    if ($resp === false) {
        throw new \RuntimeException('cURL error: ' . curl_error($ch));
    }
    curl_close($ch);
    return $resp;
}

$firstSign = generateSign('/v1/resourceProductRightsAuth', true);
$resp1 = httpRequest(
    'https://saleservice.5gtv.com.cn/v1/resourceProductRightsAuth',
    'POST',
    ['resId' => '30167', 'resourceStreamId' => '30167'],
    array_merge(
        getCommonHeaders(),
        [
            'sign: ' . $firstSign,
            'Host: saleservice.5gtv.com.cn',
        ]
    )
);
$json1 = json_decode($resp1, true);
$firstUrl = $json1['data']['url'] . '&t=1&v=203';
$parts = parse_url($firstUrl);
$uri = $parts['path'] . (isset($parts['query']) ? '?' . $parts['query'] : '');

$secondSign = generateSign($uri, true);
$resp2 = httpRequest(
    $firstUrl,
    'GET',
    null,
    array_merge(
        getCommonHeaders(),
        [
            'sign: ' . $secondSign,
            'Host: live-dispatcher.5gtv.com.cn',
        ]
    )
);
$json2 = json_decode($resp2, true);

$playUrl = $json2['data']['url'];

file_put_contents($cacheFile, $playUrl);

header('Location: ' . $playUrl);
exit;

0

主题

129

回帖

217

积分

等离子电视迷

积分
217
发表于 2025-11-26 23:12:09 来自手机 | 显示全部楼层
由酷9群搬上山几个月又搬到这里

0

主题

105

回帖

343

积分

等离子电视迷

积分
343
发表于 2025-11-27 07:24:08 | 显示全部楼层
谢谢

0

主题

81

回帖

81

积分

彩电迷

积分
81
发表于 2025-12-7 18:41:05 | 显示全部楼层
看看是啥
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋

创办于 2025 年 5 月 5 日

快速回复 返回顶部 返回列表