Example #1
0
function ShowChannel($url)
{
    global $cc, $format, $password, $PremiumUser, $quality, $username, $vlc, $windows, $cli;
    $query = $_GET["id"];
    if ($query) {
        $queryArr = explode(',', $query);
        $url = $queryArr[0];
        $disk = $queryArr[1];
    }
    $html = $cc->get($url);
    preg_match('/(flashvars.*?=.*?"&cid=.*?)(\\d+)(.*?")/i', $html, $cid);
    if (!isset($cid[2])) {
        Close("No channel id found");
    }
    // Retrieve rtmp stream info
    $cc->headers[] = "Referer: http://weeb.tv/static/player.swf";
    $response = $cc->post("http://weeb.tv/api/setPlayer", "cid={$cid['2']}&watchTime=0&firstConnect=1&ip=NaN");
    $result = explode("\r\n\r\n", $response, 2);
    $flashVars = explode("&", trim($result[1]));
    foreach ($flashVars as $flashVar) {
        $temp = explode("=", $flashVar);
        $name = strtolower($temp[0]);
        $Params[$name] = $temp[1];
    }
    //$rtmp         = str_replace("r8.", "r" . rand(1, 7) . ".", urldecode($Params["10"]));
    $rtmp = urldecode($Params["10"]);
    $playpath = urldecode($Params["11"]);
    $MultiBitrate = urldecode($Params["20"]);
    $PremiumUser = urldecode($Params["5"]);
    if ($MultiBitrate) {
        $playpath .= $quality;
    }
    $BlockType = urldecode($Params["13"]);
    print_r($Params);
    if ($BlockType != 0) {
        switch ($BlockType) {
            case 1:
                $BlockTime = urldecode($Params["14"]);
                $ReconnectionTime = urldecode($Params["16"]);
                echo '
				  
	  <?xml version="1.0" encoding="UTF8" ?>
	<rss version="2.0" xmlns:media="http://purl.org/dc/elements/1.1/" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
    <item>
    <title>You have crossed free viewing limit. you have been blocked for $BlockTime minutes. try again in $ReconnectionTime minutes.</title>
    <link>' . $disk . 'xLiveCZ/category/rss/in.php</link>
	<media:thumbnail url="' . $disk . 'image/stop.gif" />
	<mediaDisplay name=photoView
	rowCount=5
	columnCount=6
	drawItemText="no"
	showHeader="no" 
	menuBorderColor="0:0:0"
	sideColorBottom="0:0:0"
	sideColorTop="0:0:0"
	itemImageXPC="10"
	itemOffsetXPC="7"
	backgroundColor="0:0:0"
	sliding="no"
	idleImageXPC="45"
	idleImageYPC="45"
	idleImageWidthPC="8,6"
	idleImageHeightPC="6"
	itemGapYPC="2"
	itemGapXPC="1.5"
	>
		<idleImage>' . $disk . 'image/busy0.png</idleImage>
		<idleImage>' . $disk . 'image/busy1.png</idleImage>
		<idleImage>' . $disk . 'image/busy2.png</idleImage>
		<idleImage>' . $disk . 'image/busy3.png</idleImage>
		<idleImage>' . $disk . 'image/busy4.png</idleImage>
		<idleImage>' . $disk . 'image/busy5.png</idleImage>
		<idleImage>' . $disk . 'image/busy6.png</idleImage>
		<idleImage>' . $disk . 'image/busy7.png</idleImage>
		<idleImage>' . $disk . 'image/busy8.png</idleImage>
		<idleImage>' . $disk . 'image/busy9.png</idleImage>
		<image redraw="no" offsetXPC="0" offsetYPC="0" widthPC="100" heightPC="18">' . $disk . 'backgrounds/top.png</image>
		<image redraw="no" offsetXPC="3" offsetYPC="3" widthPC="10" heightPC="14">' . $disk . 'image/international.png</image>
		<text align="center" offsetXPC="0" offsetYPC="-2" widthPC="100" heightPC="20" fontSize="30" backgroundColor=-1:-1:-1 foregroundColor=250:250:250>
Sport a zahraniční</text>
	</mediaDisplay>
    </item>
	</channel>
	</rss>
    ';
                break;
            case 11:
                echo '
	  <?xml version="1.0" encoding="UTF8" ?>
	<rss version="2.0" xmlns:media="http://purl.org/dc/elements/1.1/" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
    <item>
    <title>Vycerpany pocet volnych slotu</title>
    <link>' . $disk . 'xLiveCZ/category/rss/in.php</link>
	<media:thumbnail url="' . $disk . 'image/stop.gif" />
	<mediaDisplay name=photoView
	rowCount=5
	columnCount=6
	drawItemText="no"
	showHeader="no" 
	menuBorderColor="0:0:0"
	sideColorBottom="0:0:0"
	sideColorTop="0:0:0"
	itemImageXPC="10"
	itemOffsetXPC="7"
	backgroundColor="0:0:0"
	sliding="no"
	idleImageXPC="45"
	idleImageYPC="45"
	idleImageWidthPC="8,6"
	idleImageHeightPC="6"
	itemGapYPC="2"
	itemGapXPC="1.5"
	>
		<idleImage>' . $disk . 'image/busy0.png</idleImage>
		<idleImage>' . $disk . 'image/busy1.png</idleImage>
		<idleImage>' . $disk . 'image/busy2.png</idleImage>
		<idleImage>' . $disk . 'image/busy3.png</idleImage>
		<idleImage>' . $disk . 'image/busy4.png</idleImage>
		<idleImage>' . $disk . 'image/busy5.png</idleImage>
		<idleImage>' . $disk . 'image/busy6.png</idleImage>
		<idleImage>' . $disk . 'image/busy7.png</idleImage>
		<idleImage>' . $disk . 'image/busy8.png</idleImage>
		<idleImage>' . $disk . 'image/busy9.png</idleImage>
		<image redraw="no" offsetXPC="0" offsetYPC="0" widthPC="100" heightPC="18">' . $disk . 'backgrounds/top.png</image>
		<image redraw="no" offsetXPC="3" offsetYPC="3" widthPC="10" heightPC="14">' . $disk . 'image/international.png</image>
		<text align="center" offsetXPC="0" offsetYPC="-2" widthPC="100" heightPC="20" fontSize="30" backgroundColor=-1:-1:-1 foregroundColor=250:250:250>
Sport a zahraniční</text>
	</mediaDisplay>
    </item>
	</channel>
	</rss>
    ';
                break;
            default:
                break;
        }
    }
    if (!isset($Params["73"])) {
        // Retrieve authentication token
        $response = $cc->post("http://weeb.tv/setplayer", "cid={$cid['2']}&watchTime=0&firstConnect=0&ip=NaN");
        $result = explode("\r\n\r\n", $response, 2);
        $flashVars = explode("&", trim($result[1]));
        foreach ($flashVars as $flashVar) {
            $temp = explode("=", $flashVar);
            $name = strtolower($temp[0]);
            $Params[$name] = $temp[1];
        }
    }
    if (isset($Params["73"])) {
        $token = $Params["73"];
    } else {
        Close("Server seems busy. please try after some time.");
    }
    qprintf($format, "RTMP Url", $rtmp);
    qprintf($format, "Playpath", $playpath);
    qprintf($format, "Token", $token);
    qprintf($format, "Premium", $PremiumUser ? "Yes" : "No");
    if ($username != "" && $password != "") {
        $token = "{$token};{$username};{$password}";
    } else {
        $token = "{$token};;";
    }
    $lnk = "" . $disk . "xLiveCZ/nova.sh?type=weeb&amp;url=" . $rtmp . "/" . $playpath . "&amp;w=http://static2.weeb.tv/player.swf&amp;p=http://weeb.tv&amp;y=" . $playpath . "&amp;j=" . $token . "";
    echo '
 <?xml version="1.0" encoding="UTF8" ?>
	<rss version="2.0" xmlns:media="http://purl.org/dc/elements/1.1/" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
<item>
<title>Přehrát</title>
<link>' . $lnk . '</link>
<enclosure type="video/mp4" url="' . $lnk . '"/>
</item>
	</channel>
	</rss>
    ';
    //$basecmd = 'rtmpdump -r "' . $rtmp . "/" . $playpath . '" -W "http://static2.weeb.tv/player.swf" --weeb "' . $token . "\" --live";
    // $command = $basecmd . " | \"$vlc\" -";
    if ($cli->getParam('print')) {
        echo $basecmd;
        exit(0);
    }
    /*qprintf($format, "Command", $command);
      if ($rtmp && $token)
          if ($windows)
              runAsyncBatch($command, $filename);
          else
              exec($command);*/
}
Example #2
0
function ShowChannel($url, $filename)
{
    global $cc, $cli, $format, $vlc, $windows, $xxtea;
    qecho("Retrieving html . . .\n");
    $cc->headers = $cc->headers();
    // Retrieve channel id and primary key
    $timestamp = time();
    $player_id = $url;
    $init = $cc->get("http://tvplayer.playtv.fr/js/{$player_id}.js?_={$timestamp}");
    preg_match("/b:[^{]*?({[^}]+})/i", $init, $init);
    $init = json_decode(trim($init[1]));
    if (!$init) {
        Close("Unable to retrieve initialization parameters");
    }
    $a = pack("H*", $init->{'a'});
    $b = pack("H*", $init->{'b'});
    $xxtea->setKey("object");
    $params = json_decode(trim($xxtea->decrypt($b)));
    if (!$params) {
        Close("Unable to decode initialization parameters");
    }
    $key = $xxtea->decrypt(pack("H*", $params->{'k'}));
    $xxtea->setKey($key);
    $params = json_decode(trim($xxtea->decrypt($a)));
    $channel_id = $params->{'i'};
    $api_url = $params->{'u'};
    // Generate parameter request
    $request = json_encode(array('i' => $channel_id, 't' => $timestamp, 'h' => 'playtv.fr', 'a' => 5));
    $request = unpack("H*", $xxtea->encrypt($request));
    $request = $request[1];
    $cc->headers[] = "Referer: http://static.playtv.fr/swf/tvplayer.swf?r=18";
    $cc->headers[] = "x-flash-version: 11,4,402,265";
    $response = $cc->get($api_url . $request);
    // Decode server response
    $response = pack("H*", $response);
    $params = json_decode(trim($xxtea->decrypt($response)));
    if (!$params) {
        Close("Unable to decode server response");
    }
    if (isset($params->{'s'}[1])) {
        $streams = $params->{'s'}[0]->{'bitrate'} > $params->{'s'}[1]->{'bitrate'} ? $params->{'s'}[0] : $params->{'s'}[1];
    } else {
        $streams = $params->{'s'}[0];
    }
    $scheme = $streams->{'scheme'};
    $host = $streams->{'host'};
    $port = $streams->{'port'};
    $app = $streams->{'application'};
    $playpath = $streams->{'stream'};
    $token = $streams->{'token'};
    $title = $streams->{'title'};
    // Generate authentication token for rtmp server
    $t = $params->{'j'}->{'t'};
    $k = $params->{'j'}->{'k'};
    $xxtea->setKey("object");
    $key = $xxtea->decrypt(pack("H*", $k));
    $xxtea->setKey($key);
    $auth = unpack("H*", $xxtea->encrypt($t));
    $auth = $auth[1];
    if ($scheme == "http") {
        qprintf($format, "HTTP Url", "{$scheme}://{$host}" . (isset($port) ? ":{$port}" : "") . "/{$playpath}");
    } else {
        qprintf($format, "RTMP Url", "{$scheme}://{$host}" . (isset($port) ? ":{$port}" : "") . "/{$app}");
    }
    qprintf($format, "Playpath", $playpath);
    qprintf($format, "Auth", $auth);
    $filename = SafeFileName($filename);
    if (file_exists($filename . ".flv")) {
        unlink($filename . ".flv");
    }
    if ($scheme == "http") {
        $basecmd = "{$scheme}://{$host}" . (isset($port) ? ":{$port}" : "") . "/{$playpath}";
        $command = "\"{$vlc}\" --meta-title \"{$title}\" \"{$basecmd}\"";
    } else {
        $basecmd = "rtmpdump -r \"{$scheme}://{$host}" . (isset($port) ? ":{$port}" : "") . "/{$app}\" -a \"{$app}\" -s \"http://static.playtv.fr/swf/tvplayer.swf\" -p \"http://playtv.fr/television\" -C S:{$auth} " . (isset($token) ? "-T \"{$token}\" " : "") . "--live -y \"{$playpath}\"";
        $command = $basecmd . " | \"{$vlc}\" --meta-title \"{$title}\" -";
    }
    if ($cli->getParam('print')) {
        echo $basecmd;
        exit(0);
    }
    qprintf($format, "Command", $command);
    if ($host && $playpath && $auth) {
        if ($windows) {
            runAsyncBatch($command, $filename);
        } else {
            exec($command);
        }
    }
}