<commit_before><?php
/**
 * @package plugins.youTubeDistribution
 * @subpackage lib
 */
class YouTubeDistributionRightsFeedHelper
{
	/**
	 * @var DOMDocument
	 */
	protected $_doc;

	/**
	 * @var DOMXPath
	 */
	protected $_xpath;

	/**
	 * @var string
	 */
	protected $_directoryName;

	/**
	 * @var string
	 */
	protected $_metadataTempFileName;

	public function __construct(KalturaYouTubeDistributionProfile $distributionProfile)
	{
		$this->_doc = new DOMDocument();
		$this->_doc->formatOutput = true;
		$this->_doc->appendChild($this->_doc->createElement('feed'));
		$this->_doc->createAttributeNS('http://www.youtube.com/schemas/cms/2.0','xmlns');

		$this->_xpath = new DOMXPath($this->_doc);

		$timestampName = date('Ymd-His') . '_' . time();
		$this->_directoryName = '/' . $timestampName;
		if ($distributionProfile->sftpBaseDir)
			$this->_directoryName = '/' . trim($distributionProfile->sftpBaseDir, '/') . $this->_directoryName;

		$this->_metadataTempFileName = 'youtube_xml20_' . $timestampName . '.xml';
	}

	public static function initializeDefaultSubmitFeed(KalturaYouTubeDistributionProfile $distributionProfile, $fieldValues, $videoFilePath, $thumbnailFilePath, $captionAssetIds)
	{
		$identifier= $fieldValues[KalturaYouTubeDistributionField::ASSET_CUSTOM_ID];
		$videoTag = $identifier.'-video';
		$thumbnailTag = $identifier.'-thumbnail';
		$captionTag = $identifier.'-caption';

		$feed = new YouTubeDistributionRightsFeedHelper($distributionProfile);
		$feed->setNotificationEmail($fieldValues);
		$feed->setMetadataByFieldValues($fieldValues);
		$feed->setByXpath('video/@tag', $videoTag);
		$feed->setByXpath('asset/@tag', $videoTag);

		// video file
		$urgentReference = $fieldValues[KalturaYouTubeDistributionField::URGENT_REFERENCE_FILE];
		$feed->appendFileElement('video', $urgentReference, pathinfo($videoFilePath, PATHINFO_BASENAME), $videoTag);

		// thumbnail file
		if (file_exists($thumbnailFilePath))
		{
			$feed->appendFileElement('image', false, pathinfo($thumbnailFilePath, PATHINFO_BASENAME), $thumbnailTag);
			$feed->appendVideoArtworkElement('custom_thumbnail', $thumbnailTag);
		}
		
		// Handle addition of caption asset items
		$captionAssetInfo = self::getCaptionAssetInfo($captionAssetIds); 
		foreach($captionAssetInfo as $captionInfo)
		{
			if(file_exists($captionAssetInfo['fileUrl']))
			{
				$captionTag = $captionTag . '-' . $captionAssetInfo['language'];
				$feed->appendFileElement('timed_text', false, pathinfo($captionAssetInfo['fileUrl'], PATHINFO_BASENAME), $captionTag);
				$feed->appendCaptionElement($captionTag, $captionAssetInfo['fileExt'], $captionAssetInfo['language']);
				$this->appendRelationship(array("/feed/caption[@tag='$captionTag']", "/feed/file[@tag='$captionTag']"), array("/feed/video[@tag='$videoTag']"));
			}
		}
		
		$feed->appendVideoAssetFileRelationship($fieldValues, $videoTag);
		$feed->setAdParamsByFieldValues($fieldValues, $videoTag, $distributionProfile->enableAdServer);
		$feed->appendRightsAdminByFieldValues($fieldValues, $videoTag);
<commit_msg>Mistake in using this instead of feed<commit_after><?php
/**
 * @package plugins.youTubeDistribution
 * @subpackage lib
 */
class YouTubeDistributionRightsFeedHelper
{
	/**
	 * @var DOMDocument
	 */
	protected $_doc;

	/**
	 * @var DOMXPath
	 */
	protected $_xpath;

	/**
	 * @var string
	 */
	protected $_directoryName;

	/**
	 * @var string
	 */
	protected $_metadataTempFileName;

	public function __construct(KalturaYouTubeDistributionProfile $distributionProfile)
	{
		$this->_doc = new DOMDocument();
		$this->_doc->formatOutput = true;
		$this->_doc->appendChild($this->_doc->createElement('feed'));
		$this->_doc->createAttributeNS('http://www.youtube.com/schemas/cms/2.0','xmlns');

		$this->_xpath = new DOMXPath($this->_doc);

		$timestampName = date('Ymd-His') . '_' . time();
		$this->_directoryName = '/' . $timestampName;
		if ($distributionProfile->sftpBaseDir)
			$this->_directoryName = '/' . trim($distributionProfile->sftpBaseDir, '/') . $this->_directoryName;

		$this->_metadataTempFileName = 'youtube_xml20_' . $timestampName . '.xml';
	}

	public static function initializeDefaultSubmitFeed(KalturaYouTubeDistributionProfile $distributionProfile, $fieldValues, $videoFilePath, $thumbnailFilePath, $captionAssetIds)
	{
		$identifier= $fieldValues[KalturaYouTubeDistributionField::ASSET_CUSTOM_ID];
		$videoTag = $identifier.'-video';
		$thumbnailTag = $identifier.'-thumbnail';
		$captionTag = $identifier.'-caption';

		$feed = new YouTubeDistributionRightsFeedHelper($distributionProfile);
		$feed->setNotificationEmail($fieldValues);
		$feed->setMetadataByFieldValues($fieldValues);
		$feed->setByXpath('video/@tag', $videoTag);
		$feed->setByXpath('asset/@tag', $videoTag);

		// video file
		$urgentReference = $fieldValues[KalturaYouTubeDistributionField::URGENT_REFERENCE_FILE];
		$feed->appendFileElement('video', $urgentReference, pathinfo($videoFilePath, PATHINFO_BASENAME), $videoTag);

		// thumbnail file
		if (file_exists($thumbnailFilePath))
		{
			$feed->appendFileElement('image', false, pathinfo($thumbnailFilePath, PATHINFO_BASENAME), $thumbnailTag);
			$feed->appendVideoArtworkElement('custom_thumbnail', $thumbnailTag);
		}
		
		// Handle addition of caption asset items
		$captionAssetInfo = self::getCaptionAssetInfo($captionAssetIds); 
		foreach($captionAssetInfo as $captionInfo)
		{
			if(file_exists($captionAssetInfo['fileUrl']))
			{
				$captionTag = $captionTag . '-' . $captionAssetInfo['language'];
				$feed->appendFileElement('timed_text', false, pathinfo($captionAssetInfo['fileUrl'], PATHINFO_BASENAME), $captionTag);
				$feed->appendCaptionElement($captionTag, $captionAssetInfo['fileExt'], $captionAssetInfo['language']);
				$feed->appendRelationship(array("/feed/caption[@tag='$captionTag']", "/feed/file[@tag='$captionTag']"), array("/feed/video[@tag='$videoTag']"));
			}
		}
		
		$feed->appendVideoAssetFileRelationship($fieldValues, $videoTag);
		$feed->setAdParamsByFieldValues($fieldValues, $videoTag, $distributionProfile->enableAdServer);
		$feed->appendRightsAdminByFieldValues($fieldValues, $videoTag);

{'fraction_non_alphanumeric': 0.1597652429083795, 'fraction_numerical': 0.0013042060645582002, 'mean_word_length': 6.209165687426557, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, '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': '7155708', 'n_tokens_mistral': 2055, 'n_tokens_neox': 1832, 'n_words': 266}