1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
| <?php
$id = isset($_GET['id']) ? $_GET['id'] : '-1';
$ts = isset($_GET['ts']) ? $_GET['ts'] : '-1';
if($id !== '-1'){
$baseurl = 'https://iptv.stream/';
$header = array(
'Referer: https://iptv.stream/'
);
// 获取 m3u8
// 流媒体的链接为 https://iptv.stream/100/index.php
$url = $baseurl.$id.'/index.php';
$res = get($url, $header, $e_url);
$reg = '/(.*?.m3u8)/';
preg_match($reg, $res, $arr);
$str = $arr[1];
// 获取 ts
$baseurl = dirname($e_url);
$str = $baseurl.'/'.$str;
$res = get($str, $header, $e_url);
$reg = '/(.*\.ts)/i';
preg_match_all($reg, $res, $arr);
foreach ($arr[1] as $key => $value){
$res = str_replace($value, 'iptv-sample-c.php?ts='.strtr(base64_encode("$baseurl/$value"), '+/', '-_'), $res);
}
echo($res);
}else if($ts !== '-1'){
$header = array(
'Referer: https://iptv.stream/'
);
$decoded_ts = base64_decode(strtr($ts, '-_', '+/'));
$res = ts($decoded_ts, $header);
}
function get($url, $header, &$e_url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$result = curl_exec($ch);
$e_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
curl_close($ch);
return $result;
}
function ts($url, $header){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$result = curl_exec($ch);
curl_close($ch);
}
|