Ejemplo n.º 1
0
    $asset_id = trim(fgets(STDIN));
} else {
    $channel_id = $argv[1];
    $asset_id = $argv[2];
}
echo "Retrieving html . . .\n";
$xml = file_get_contents("http://player.vidaroo.com/initiate/render/channel_id/{$channel_id}/asset_id/{$asset_id}/embed_id/2105/log_embed_id/128210038");
$xml = simplexml_load_string($xml);
$token = $xml->xpath('/rsp/msg/session/token');
$token = (string) $token[0];
printf($format, "Token", $token);
$xml = file_get_contents("http://player.vidaroo.com/render/asset/channel_id/{$channel_id}/asset_id/{$asset_id}/token/{$token}");
$xml = simplexml_load_string($xml);
$title = $xml->xpath('/rsp/msg/slot/video/asset/title');
$title = (string) $title[0];
$filename = SafeFileName($title);
$url = $xml->xpath('/rsp/msg/slot/video/asset/@url');
$url = base64_decode((string) $url[0]);
$host = substr($url, 0, strpos($url, '/', 8));
$app = substr($url, strlen($host) + 1, strrpos($url, '/') - strlen($host));
$playpath = substr(strrchr($url, '/'), 1);
$command = 'rtmpdump -r "' . "{$host}/{$app}" . '" -a "' . $app . '" -f "WIN 11,1,102,63" -W "http://assets.vidaroo.com/platform/1331760804/player/shell.swf" -p "http://www.power106.com/powertv/index.aspx" -C B:1 -y "mp4:' . $playpath . '" -o "' . $filename . '.flv"';
printf($format, "Title", $title);
printf($format, "Host", $host);
printf($format, "App", $app);
printf($format, "Playpath", $playpath);
printf($format, "Command", $command);
if ($playpath) {
    runAsyncBatch($command, $filename);
}
echo "Finished\n";
Ejemplo n.º 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);
        }
    }
}