// parse command line
$options = KalturaCommandLineParser::parseArguments($commandLineSwitches);
$arguments = KalturaCommandLineParser::stripCommandLineSwitches($commandLineSwitches, $argv);
if (!$arguments) {
    $usage = "Usage: generateKs [switches] <partnerId>\nOptions:\n";
    $usage .= KalturaCommandLineParser::getArgumentsUsage($commandLineSwitches);
    die($usage);
}
$partnerId = $arguments[0];
KalturaSecretRepository::init();
$adminSecret = KalturaSecretRepository::getAdminSecret($partnerId);
if (!$adminSecret) {
    die("Failed to get secret for partner {$partnerId}");
}
$type = isset($options['type']) ? $options['type'] : 2;
$user = isset($options['user']) ? $options['user'] : '******';
$expiry = isset($options['expiry']) ? $options['expiry'] : 86400;
$privileges = isset($options['privileges']) ? $options['privileges'] : 'disableentitlement';
if (isset($options['widget'])) {
    $type = 0;
    $user = '******';
    $expiry = 86400;
    $privileges = 'widget:1,view:*';
}
if (!isset($options['bare'])) {
    echo "ks\t";
}
echo KalturaSession::generateKsV1($adminSecret, $user, $type, $partnerId, $expiry, $privileges, null, null);
if (!isset($options['bare'])) {
    echo "\n";
}