Example #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";
Example #2
0
function ShowChannel($url, $filename)
{
    global $cc, $cli, $format, $password, $PremiumUser, $quality, $username, $vlc, $windows;
    LogInfo("Retrieving info....");
    $cc->headers = $cc->headers();
    $cid = substr($url, strrpos($url, '/') + 1);
    if (!$cid) {
        Close("No channel id found");
    }
    // Retrieve rtmp stream info
    $cc->headers[] = "Referer: http://static.weeb.tv/player.swf";
    $Params = GetApiResponse($cc, "http://weeb.tv/api/setPlayer", "cid=" . $cid . "&watchTime=0&firstConnect=1&ip=NaN");
    if (isset($Params[0]) and $Params[0] <= 0) {
        Close("Server refused to send required parameters.");
    }
    $rtmp = $Params["10"];
    $playpath = $Params["11"];
    $MultiBitrate = $Params["20"];
    $PremiumUser = $Params["5"];
    if ($MultiBitrate) {
        $playpath .= $quality;
    }
    $BlockType = $Params["13"];
    if ($BlockType != 0) {
        switch ($BlockType) {
            case 1:
                $BlockTime = $Params["14"];
                $ReconnectionTime = $Params["16"];
                Close("You have crossed free viewing limit. you have been blocked for {$BlockTime} minutes. try again in {$ReconnectionTime} minutes.");
                break;
            case 11:
                Close("No free slots available");
                break;
            default:
                break;
        }
    }
    // Retrieve authentication token
    if (!isset($Params["73"])) {
        $Params = GetApiResponse($cc, "http://weeb.tv/api/setPlayer", "cid=" . $cid . "&watchTime=0&firstConnect=0&ip=NaN");
    }
    if (isset($Params["73"])) {
        $token = $Params["73"];
    } else {
        Close("Server seems busy, please try after some time.");
    }
    LogInfo(sprintf($format, "RTMP Url", $rtmp));
    LogInfo(sprintf($format, "Playpath", $playpath));
    LogInfo(sprintf($format, "Token", $token));
    LogInfo(sprintf($format, "Premium", $PremiumUser ? "Yes" : "No"));
    if ($username != "" && $password != "") {
        $token = "{$token};{$username};{$password}";
    }
    $filename = SafeFileName($filename);
    if (file_exists($filename . ".flv")) {
        unlink($filename . ".flv");
    }
    $basecmd = 'rtmpdump -r "' . $rtmp . "/" . $playpath . '" -W "http://static.weeb.tv/player.swf" --weeb "' . $token . "\" --live";
    $command = $basecmd . " | \"{$vlc}\" --meta-title \"{$filename}\" -";
    if ($cli->getParam('print')) {
        printf($basecmd);
        exit(0);
    }
    LogInfo(sprintf($format, "Command", $command));
    if ($rtmp && $token) {
        if ($windows) {
            RunAsyncBatch($command, $filename);
        } else {
            exec($command);
        }
    }
}
Example #3
0
 public function testSafeFileName()
 {
     $this->assertEquals("testtest", SafeFileName('test\\/:*?"<>|test'));
 }
Example #4
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);
        }
    }
}
Example #5
0
if (count($matches) < 5) {
    die("Could not parse '{$original}'");
}
// Create the search parameters.
$search = array();
$search['episode'] = intval(end($matches));
prev($matches);
// Skip the season/ep delimiter.
$search['season'] = intval(prev($matches));
$search['show'] = trim(prev($matches));
// Perform the search and split the data info into a map.
$data = file_get_contents(sprintf(SEARCH_URL, urlencode($search['show']), $search['season'], $search['episode']));
$info = array();
array_map(function ($s) {
    global $info;
    if (!empty($s)) {
        $parts = explode('@', $s);
        $info[$parts[0]] = $parts[1];
    }
}, explode("\n", $data));
// If we received the information we require, perform the rename.
if (isset($info['Show Name']) && isset($info['Episode Info'])) {
    $epinfo = explode('^', $info['Episode Info']);
    $new = $info['Show Name'] . ' - ' . $search['season'] . 'x' . $search['episode'] . ' - ' . $epinfo[1];
    // If this is a directory, store the old name.
    if (is_dir($path)) {
        file_put_contents($path . '/renamed.txt', $original);
    }
    // Perform the rename.
    rename($path, dirname($path) . '/' . SafeFileName($new));
}