Update index.php
Browse files
index.php
CHANGED
@@ -1,141 +1,44 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
"context" => "",
|
21 |
-
"version" => "2.4",
|
22 |
-
"data" => new stdClass(),
|
23 |
-
];
|
24 |
-
$postData = json_encode($arr);
|
25 |
-
$headers = array(
|
26 |
-
'Content-Type: application/json',
|
27 |
-
'Content-Length: ' . strlen($postData),
|
28 |
-
'upgrade-insecure-requests: 1',
|
29 |
-
'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36'
|
30 |
-
);
|
31 |
-
}
|
32 |
-
$ch = curl_init();
|
33 |
-
curl_setopt($ch, CURLOPT_URL, $apiurl);
|
34 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
35 |
-
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
36 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
37 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
38 |
-
if ($flag == "uid") {
|
39 |
-
curl_setopt($ch, CURLOPT_POST, 1);
|
40 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
|
41 |
-
}
|
42 |
-
$data = curl_exec($ch);
|
43 |
-
curl_close($ch);
|
44 |
-
return $data;
|
45 |
-
}
|
46 |
-
|
47 |
-
function aes_decrypt($ciphertext, $key, $iv)
|
48 |
-
{
|
49 |
-
return openssl_decrypt($ciphertext, 'AES-256-CBC', $key, 0, $iv);
|
50 |
-
}
|
51 |
-
|
52 |
-
$key = "abcdefghijklmnopqrstuvwxyz123456";
|
53 |
-
$iv = "1234567890123456";
|
54 |
-
$mediaurl = aes_decrypt("vcnTSiZsSUWtlZRxx+FuRnM7F1b1FlSVueFKcxewvKVbe9bXE49HXuq1dHha2K7cSic4yOuClWpau1RibQeO2g==", $key, $iv);
|
55 |
-
|
56 |
-
$uid = json_decode(get_content("https://udblgn.huya.com/web/anonymousLogin", "uid"), true)["data"]["uid"];
|
57 |
-
|
58 |
-
function get_uuid()
|
59 |
-
{
|
60 |
-
$now = intval(microtime(true) * 1000);
|
61 |
-
$rand = rand(0, 1000) | 0;
|
62 |
-
return intval(($now % 10000000000 * 1000 + $rand) % 4294967295);
|
63 |
-
}
|
64 |
-
|
65 |
-
function process_anticode($anticode, $uid, $streamname)
|
66 |
-
{
|
67 |
-
parse_str($anticode, $q);
|
68 |
-
$q["ver"] = "1";
|
69 |
-
$q["sv"] = "2110211124";
|
70 |
-
$q["seqid"] = strval(intval($uid) + intval(microtime(true) * 1000));
|
71 |
-
$q["uid"] = strval($uid);
|
72 |
-
$q["uuid"] = strval(get_uuid());
|
73 |
-
$ss = md5("{$q["seqid"]}|{$q["ctype"]}|{$q["t"]}");
|
74 |
-
$q["fm"] = base64_decode($q["fm"]);
|
75 |
-
$q["fm"] = str_replace(["$0", "$1", "$2", "$3"], [$q["uid"], $streamname, $ss, $q["wsTime"]], $q["fm"]);
|
76 |
-
$q["wsSecret"] = md5($q["fm"]);
|
77 |
-
unset($q["fm"]);
|
78 |
-
if (array_key_exists("txyp", $q)) {
|
79 |
-
unset($q["txyp"]);
|
80 |
-
}
|
81 |
-
return http_build_query($q);
|
82 |
-
}
|
83 |
-
|
84 |
-
function format($livearr, $uid)
|
85 |
-
{
|
86 |
-
$stream_info = ['flv' => [], 'hls' => []];
|
87 |
-
$cdn_type = ['HY' => 'hycdn', 'AL' => 'alicdn', 'TX' => 'txcdn', 'HW' => 'hwcdn', 'HS' => 'hscdn', 'WS' => 'wscdn'];
|
88 |
-
foreach ($livearr["roomInfo"]["tLiveInfo"]["tLiveStreamInfo"]["vStreamInfo"]["value"] as $s) {
|
89 |
-
if ($s["sFlvUrl"]) {
|
90 |
-
$stream_info["flv"][$cdn_type[$s["sCdnType"]]] = $s["sFlvUrl"] . '/' . $s["sStreamName"] . '.' . $s["sFlvUrlSuffix"] . '?' . process_anticode($s["sFlvAntiCode"], $uid, $s["sStreamName"]);
|
91 |
-
}
|
92 |
-
if ($s["sHlsUrl"]) {
|
93 |
-
$stream_info["hls"][$cdn_type[$s["sCdnType"]]] = $s["sHlsUrl"] . '/' . $s["sStreamName"] . '.' . $s["sHlsUrlSuffix"] . '?' . process_anticode($s["sHlsAntiCode"], $uid, $s["sStreamName"]);
|
94 |
-
}
|
95 |
-
}
|
96 |
-
return $stream_info;
|
97 |
-
}
|
98 |
-
|
99 |
-
$res = get_content($roomurl, "mobile");
|
100 |
-
$reg = "/\<script\> window.HNF_GLOBAL_INIT = (.*) \<\/script\>/i";
|
101 |
-
preg_match($reg, $res, $realres);
|
102 |
-
$realdata = json_decode($realres[1], true);
|
103 |
-
|
104 |
-
if (in_array(0, $realdata) or in_array(1, $realdata)) {
|
105 |
-
header('location:' . $mediaurl);
|
106 |
-
exit();
|
107 |
-
} elseif ($realdata["roomInfo"]["eLiveStatus"] == 2) {
|
108 |
-
$realurl = format($realdata, $uid);
|
109 |
-
if ($type == "display") {
|
110 |
-
print_r($realurl);
|
111 |
-
exit();
|
112 |
-
}
|
113 |
-
if ($media == "flv") {
|
114 |
-
switch ($cdn) {
|
115 |
-
case $cdn:
|
116 |
-
$mediaurl = $realurl["flv"][$cdn];
|
117 |
-
break;
|
118 |
-
default:
|
119 |
-
$mediaurl = $realurl["flv"]["hwcdn"];
|
120 |
-
break;
|
121 |
-
}
|
122 |
-
}
|
123 |
-
if ($media == "hls") {
|
124 |
-
switch ($cdn) {
|
125 |
-
case $cdn:
|
126 |
-
$mediaurl = $realurl["hls"][$cdn];
|
127 |
-
break;
|
128 |
-
default:
|
129 |
-
$mediaurl = $realurl["hls"]["hwcdn"];
|
130 |
-
break;
|
131 |
-
}
|
132 |
-
}
|
133 |
-
header('location:' . $mediaurl);
|
134 |
-
exit;
|
135 |
-
} elseif ($realdata["roomInfo"]["eLiveStatus"] == 3) {
|
136 |
-
header('location:' . "http:" . base64_decode($realdata["roomProfile"]["liveLineUrl"]));
|
137 |
exit();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
} else {
|
139 |
-
header('location:'
|
140 |
-
|
141 |
-
}
|
|
|
1 |
<?php
|
2 |
+
/*
|
3 |
+
.php?id=0&hq 無線新聞台1080P
|
4 |
+
.php?id=0 無線新聞台720P
|
5 |
+
.php?id=1 無線新聞台360P
|
6 |
+
.php?id=2&hq 無線財經·體育·資訊台1080P
|
7 |
+
.php?id=2 無線財經·體育·資訊台720P
|
8 |
+
.php?id=3 無線財經·體育·資訊台360P
|
9 |
+
.php?id=4&hq 事件直播頻道1 1080P(全清晰度)
|
10 |
+
.php?id=4 事件直播頻道1 720P
|
11 |
+
.php?id=5 事件直播頻道1 576P
|
12 |
+
.php?id=6&hq 事件直播頻道2 1080P(全清晰度)
|
13 |
+
.php?id=6 事件直播頻道2 720P
|
14 |
+
.php?id=7 事件直播頻道2 576P
|
15 |
+
*/
|
16 |
+
$id = $_GET['id'];
|
17 |
+
$ids = ['I-NEWS','I-NEWS','I-FINA','I-FINA','NEVT1','NEVT1','NEVT2','NEVT2'];
|
18 |
+
$hq = $_GET['hq'];
|
19 |
+
if(!isset($ids[$id])) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
exit();
|
21 |
+
};
|
22 |
+
$header[] = 'CLIENT-IP:127.0.0.1';
|
23 |
+
$header[] = 'X-FORWARDED-FOR:127.0.0.1';
|
24 |
+
$ch = curl_init();
|
25 |
+
curl_setopt($ch,CURLOPT_URL,'https://inews-api.tvb.com/news/checkout/live/hd/ott_'.$ids[$id].'_h264?profile=safari');
|
26 |
+
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
|
27 |
+
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
|
28 |
+
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
|
29 |
+
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
|
30 |
+
$data = curl_exec($ch);
|
31 |
+
curl_close($ch);
|
32 |
+
$json = json_decode($data);
|
33 |
+
$url = $json->content->url;
|
34 |
+
if(isset($hq)) {
|
35 |
+
if($id == '4' || $id == '5' || $id == '6' || $id == '7') {
|
36 |
+
header('location:'.preg_replace('/&p=(.*?)$/','',$url->hd));
|
37 |
+
} else {
|
38 |
+
header('location:'.preg_replace('/&p=(.*?)$/','&p=3000',$url->hd));
|
39 |
+
};
|
40 |
+
} else if($id == '0' || $id == '2' || $id == '4' || $id == '6') {
|
41 |
+
header('location:'.$url->hd);
|
42 |
} else {
|
43 |
+
header('location:'.$url->sd);
|
44 |
+
};
|
|