<commit_before><?php
/**
 * @package plugins.remoteMediaInfo
 * @subpackage lib
 */
class KRemoteMediaInfoMediaParser  extends KMediaInfoMediaParser
{
	protected $taskConfig;
	
	/**
	 * @param string $filePath
	 * @param KSchedularTaskConfig $taskConfig
	 */
	public function __construct($filePath, KSchedularTaskConfig $taskConfig)
	{
		$this->taskConfig = $taskConfig;
		$this->filePath = $filePath;
		
		$errStr=null;
		if(!$taskConfig->params->AlldigitalApiUrl)
			$errStr="AlldigitalApiUrl";
		if(!$taskConfig->params->AlldigitalApiUser){
			if($errStr) 
				$errStr.=",";
			$errStr.="AlldigitalApiUser";
		}
		if(!$taskConfig->params->AlldigitalApiPassword){
			if($errStr) 
				$errStr.=",";
			$errStr.="AlldigitalApiPassword";
		}
		
		KalturaLog::info("taskConfig-->".print_r($taskConfig,true));
		if($errStr) {
			KalturaLog::info("AlldigitalApi failure: missing credentials - $errStr");
			throw new KOperationEngineException("AlldigitalApi failure: missing credentials - $errStr");
		}
	}
	
	/**
	 * @return string
	 */
	public function getRawMediaInfo()
	{
		$adApi=new ADContentAPI;
		$adApi->setUser($this->taskConfig->params->AlldigitalApiUser);
		$adApi->setPassw($this->taskConfig->params->AlldigitalApiPassword);
		$adApi->setUrl($this->taskConfig->params->AlldigitalApiUrl);
KalturaLog::info("adApi-->".print_r($adApi,true));

		$mi=$adApi->MediaInfoToText("input",'ABCNEWS_SD_CONSMEDIA_e.mxf', $err);
KalturaLog::info("mediaInfo-->\n".$mi);<commit_msg>fwr: Alldigital intergration 'job' arg is used by the remote media info to get the AD conection and other data.<commit_after><?php
/**
 * @package plugins.remoteMediaInfo
 * @subpackage lib
 */
class KRemoteMediaInfoMediaParser  extends KMediaInfoMediaParser
{
	protected $taskConfig;
	
	/**
	 * @param string $filePath
	 * @param KSchedularTaskConfig $taskConfig
	 */
	public function __construct($job, KSchedularTaskConfig $taskConfig)
	{
		$this->taskConfig = $taskConfig;
		$this->job = $job;
		
		$errStr=null;
		if(!$taskConfig->params->AlldigitalApiUrl)
			$errStr="AlldigitalApiUrl";
		if(!$taskConfig->params->AlldigitalApiUser){
			if($errStr) 
				$errStr.=",";
			$errStr.="AlldigitalApiUser";
		}
		if(!$taskConfig->params->AlldigitalApiPassword){
			if($errStr) 
				$errStr.=",";
			$errStr.="AlldigitalApiPassword";
		}
		
//KalturaLog::info("taskConfig-->".print_r($taskConfig,true));
//KalturaLog::info("job-->".print_r($job,true));
		if($errStr) {
			KalturaLog::info("AlldigitalApi: missing credentials - $errStr");
			throw new KOperationEngineException("AlldigitalApi: missing credentials - $errStr");
		}
	}
	
	/**
	 * @return string
	 */
	public function getRawMediaInfo()
	{
		$adApi=new ADContentAPI;
		$adApi->setUser($this->taskConfig->params->AlldigitalApiUser);
		$adApi->setPassw($this->taskConfig->params->AlldigitalApiPassword);
		$adApi->setUrl($this->taskConfig->params->AlldigitalApiUrl);
KalturaLog::info("adApi-->".print_r($adApi,true));
		
		$fileName=$this->job->data->srcFileSyncLocalPath;
			// Calls from PostConvertJob represent 'output' AD location,
			// while calls from ExtractMediaJob represnt 'input' AD location
		if($this->job->data instanceof KalturaPostConvertJobData){
			$location='output';
			$folder=str_replace ("-", "/", $this->job->data->srcFileSyncRemoteUrl);
			$fileName="$folder/encode/$fileName";
		}
		else // if($this->job->data instanceof KalturaExtractMediaJobData)
			$location='input';
		$mi=$adApi->MediaInfoToText($location,$fileName, $err);
		if(!isset($mi)){
			KalturaLog::info("AlldigitalApi: mediainfo failure(location:$location,fileName:$fileName) - $err");
			throw new KOperationEngineException("AlldigitalApi: mediainfo failure(location:$location,fileName:$fileName) - $err");
		}
KalturaLog::info("mediaInfo-->\n".$mi);
{'fraction_non_alphanumeric': 0.16834303864478561, 'fraction_numerical': 0.0, 'mean_word_length': 5.4268707482993195, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 62, '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': '5010733', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1302, 'n_words': 186}