<commit_before><?php

class flavorCustomData {

	var $data;
	public $requireSerialization = true;
	private $logger;

	function __construct() {
	    $this->logger = Logger::getLogger("UDRM");
	}

	function run(){
        $this->logger->info("Start UDRM process");
        $timer = new Timer();
        $timer->start();
        
	    global $wgKalturaUdrmSecret;
	    global $wgTvpapiAccountId;
	    global $wgKalturaUdrmEncryptionServer;
        $custom_data = array();
	    $reqData = DataStore::getInstance()->getData("request");
	    if (isset ($reqData) &&
	        isset ($reqData["initObj"]) &&
	        isset ($reqData["initObj"]["SiteGuid"]) &&
	        isset ($reqData["initObj"]["UDID"])){
            $siteGuid = $reqData["initObj"]["SiteGuid"];
            $udid = $reqData["initObj"]["UDID"];
            $flavorassets = DataStore::getInstance()->getData("flavorassets");
            $flavorCustomData = array();
            if (isset($flavorassets["Files"])){
                foreach ($flavorassets["Files"] as $key => $val) {
                    $data = json_encode(array(
                        "ca_system" => 'OTT',
                        "user_token" => $siteGuid,
                        "account_id" => $wgTvpapiAccountId,
                        "content_id" => $val["CoGuid"],
                        "files" => "",
                        "udid" => $udid
                    ));

                    $this->logger->debug("Flavor UDRM metadata: " . $data);

                    $custom_data = rawurlencode(base64_encode($data));
                    $signature = rawurlencode(base64_encode(sha1($wgKalturaUdrmSecret . $data, true)));

                    $encryptionUrl = $wgKalturaUdrmEncryptionServer."?custom_data=".$custom_data."&signature=".$signature;
                    $this->logger->info("UDRM encryption request: " . $encryptionUrl);
                    $response = $this->getJson($encryptionUrl);
                    $this->logger->debug("UDRM encryption response: " . json_encode($response));
                    $contentId = "";
                    if (isset($response) && is_array($response) && isset($response[0]) && isset($response[0]["key_id"])){
                        $contentId = $response[0]["key_id"];
                    }
                    $flavorCustomData[ $val["FileID"] ] = array(
                        "custom_data" => $custom_data,
                        "signature" => $signature,
                        "contentId" => $contentId
                    );
                    $this->logger->debug("Flavor UDRM data: " . json_encode($flavorCustomData[ $val["FileID"] ]));
                }<commit_msg>Request UDRM contend only for smoothStream content<commit_after><?php

class flavorCustomData {

	var $data;
	public $requireSerialization = true;
	private $logger;

	function __construct() {
	    $this->logger = Logger::getLogger("UDRM");
	}

	function run(){
        $this->logger->info("Start UDRM process");
        $timer = new Timer();
        $timer->start();
        
	    global $wgKalturaUdrmSecret;
	    global $wgTvpapiAccountId;
	    global $wgKalturaUdrmEncryptionServer;
        $custom_data = array();
	    $reqData = DataStore::getInstance()->getData("request");
	    if (isset ($reqData) &&
	        isset ($reqData["initObj"]) &&
	        isset ($reqData["initObj"]["SiteGuid"]) &&
	        isset ($reqData["initObj"]["UDID"])){
            $siteGuid = $reqData["initObj"]["SiteGuid"];
            $udid = $reqData["initObj"]["UDID"];
            $flavorassets = DataStore::getInstance()->getData("flavorassets");
            $flavorCustomData = array();
            if (isset($flavorassets["Files"])){
                foreach ($flavorassets["Files"] as $key => $val) {
                    $data = json_encode(array(
                        "ca_system" => 'OTT',
                        "user_token" => $siteGuid,
                        "account_id" => $wgTvpapiAccountId,
                        "content_id" => $val["CoGuid"],
                        "files" => "",
                        "udid" => $udid
                    ));

                    $this->logger->debug("Flavor UDRM metadata: " . $data);

                    $custom_data = rawurlencode(base64_encode($data));
                    $signature = rawurlencode(base64_encode(sha1($wgKalturaUdrmSecret . $data, true)));

                    $flavorCustomData[ $val["FileID"] ] = array(
                        "custom_data" => $custom_data,
                        "signature" => $signature
                    );

                    if (isset($val["URL"]) && (strpos($val["URL"], 'ism') !== false))
                    {
                        $encryptionUrl = $wgKalturaUdrmEncryptionServer."?custom_data=".$custom_data."&signature=".$signature;
                        $this->logger->info("UDRM encryption request: " . $encryptionUrl);
                        $response = $this->getJson($encryptionUrl);
                        $this->logger->debug("UDRM encryption response: " . json_encode($response));
                        $contentId = "";
                        if (isset($response) && is_array($response) && isset($response[0]) && isset($response[0]["key_id"])){
                            $contentId = $response[0]["key_id"];
                        }
                        $flavorCustomData[ $val["FileID"] ]["contentId"] = $contentId;
                    }

                    $this->logger->debug("Flavor UDRM data: " . json_encode($flavorCustomData[ $val["FileID"] ]));

                }
{'fraction_non_alphanumeric': 0.1561037090385308, 'fraction_numerical': 0.0028808066258552397, 'mean_word_length': 1.8041393235739525, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1444350', 'n_tokens_mistral': 1573, 'n_tokens_neox': 1481, 'n_words': 241}