forked from allscriptz/jiotv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
m3u8.php
64 lines (38 loc) · 1.58 KB
/
m3u8.php
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
62
63
64
<?php
/* The following code retrieves the m3u8 playlist from JioTV
Replace http://url_to_token/ with the URL to Jio token
Usage format: http://localhost/m3u8.php?c=9XM&q=600
Contributed by: [email protected]
*/
header("Content-Type: application/vnd.apple.mpegurl");
header("Access-Control-Allow-Origin: *");
header("Access-Control-Expose-Headers: Content-Length,Content-Range");
header("Access-Control-Allow-Headers: Range");
header("Accept-Ranges: bytes");
$cache= (string)date("dHi") . ".txt";
if(!file_exists($cache)){
$p= @file_get_contents("http://url_to_token/");
file_put_contents($cache, $p);
}
else
{
$p=file_get_contents($cache);
}
if($p!="" && @$_REQUEST["c"]!=""){
$opts = [
"http" => [
"method" => "GET",
"header" => "User-Agent: plaYtv/5.3.2 (Linux;Android 5.1.1) ExoPlayerLib/2.3.0\r\n"
]
];
$cx = stream_context_create($opts);
$hs = file_get_contents("http://mumsite.cdnsrv.jio.com/jiotv.live.cdn.jio.com/" . $_REQUEST["c"] . "/" . $_REQUEST["c"] . "_" . $_REQUEST["q"] . ".m3u8" . $p,false,$cx);
$hs= @preg_replace("/" . $_REQUEST["c"] . "_" . $_REQUEST["q"] ."-([^.]+\.)key/", $_REQUEST["c"] . '_' . $_REQUEST["q"] . '-\1key' . $p, $hs);
//adds $p to the key url
$hs= @preg_replace("/" . $_REQUEST["c"] . "_" . $_REQUEST["q"] ."-([^.]+\.)ts/", 'http://mumsite.cdnsrv.jio.com/jiotv.live.cdn.jio.com/' . $_REQUEST["c"] . '/' . $_REQUEST["c"] . '_' . $_REQUEST["q"] . '-\1ts', $hs);
/*
Proxy the .ts and .key files through file_get_contents() if needed
*/
echo $hs;
}
?>