<commit_before>/**
 * VAST ad parser ( presently just works with VAST once there are more ad formats
 * we could abstract common parts of this parser process.
 */
( function( mw, $ ) { "use strict";

mw.VastAdParser = {
	/**
	 * VAST support
	 * Convert the vast ad display format into a display conf:
	 */
	parse: function( xmlObject ){
		var _this = this;
		var adConf = {};
		var $vast = $( xmlObject );
		// Get the basic set of sequences
		adConf.ads = [];
		$vast.find( 'Ad' ).each( function( inx, node ){
			mw.log( 'VastAdParser:: getVastAdDisplayConf: ' + node );
			var $ad = $( node );

			// Set a local pointer to the current sequence:
			var currentAd = { 'id' : $( node ).attr('id') };

			// Set duration
			if( $ad.find('duration') ){
				currentAd.duration = mw.npt2seconds( $ad.find( 'duration' ).text() );
			}

			// Set impression urls
			currentAd.impressions = [];
			$ad.find( 'Impression' ).each( function(na, node){
				// Check if there is lots of impressions or just one:
				if( $(node).find('URL').length ){
					$ad.find('URL').each( function( na, urlNode ){
						currentAd.impressions.push({
							'beaconUrl' : _this.getURLFromNode( urlNode ),
							'idtype' : $( urlNode ).attr('id')
						});
					});
				} else {
					currentAd.impressions.push({
						'beaconUrl' : _this.getURLFromNode( node )
					});
				}
			});

			// Set Non Linear Ads
			currentAd.nonLinear = [];
			$ad.find( 'NonLinearAds NonLinear' ).each( function( na, nonLinearNode ){
				var staticResource = _this.getResourceObject( nonLinearNode );
				if( staticResource ){
					// Add the staticResource to the ad config:
					currentAd.nonLinear.push( staticResource );
				}
			});

			// Set tracking events:
			currentAd.trackingEvents = [];
			// Check for Linear descendant ( double click vast XML has multiple trackingEvents per Linear and non-Linear and
			var selector = 'trackingEvents Tracking';
			if( $ad.find( 'InLine Linear').length ){
				selector = 'InLine Linear ' + selector;
			}
			$ad.find( selector ).each( function( na, trackingNode ){
				currentAd.trackingEvents.push({
					'eventName' : $( trackingNode ).attr('event'),
					'beaconUrl' : _this.getURLFromNode( trackingNode )
				});
			});

			currentAd.videoFiles = [];
			// Set the media file:
			$ad.find('MediaFiles MediaFile').each( function( na, mediaFile ){
				// Add the video source ( if an html5 compatible type )
				var type  = $( mediaFile ).attr('type');
				// Normalize mp4 into h264 format:
				if( type  == 'video/x-mp4' || type == 'video/mp4' ){
					type = 'video/h264';
				}

				if(  type == 'video/h264' || type == 'video/ogg' || type == 'video/webm' ){
					var source = {
							'src' :_this.getURLFromNode( mediaFile ),
							'type' : type
						};
					if( $( mediaFile ).attr('bitrate') ){
						source['data-bandwith']  = $( mediaFile ).attr('bitrate')* 1024;
					}
					if( $( mediaFile ).attr('width') ){
						source['data-width'] =  $( mediaFile ).attr('width');
					}
					if( $( mediaFile ).attr('height') ){
						source['data-height'] =  $( mediaFile ).attr('height');
					}
					// Add the source object:
					currentAd.videoFiles.push( source );
					mw.log( "VastAdParser::add MediaFile:" + currentAd.videoFile );
				}
			});
<commit_msg>VAST: fixed log for adding media<commit_after>/**
 * VAST ad parser ( presently just works with VAST once there are more ad formats
 * we could abstract common parts of this parser process.
 */
( function( mw, $ ) { "use strict";

mw.VastAdParser = {
	/**
	 * VAST support
	 * Convert the vast ad display format into a display conf:
	 */
	parse: function( xmlObject ){
		var _this = this;
		var adConf = {};
		var $vast = $( xmlObject );
		// Get the basic set of sequences
		adConf.ads = [];
		$vast.find( 'Ad' ).each( function( inx, node ){
			mw.log( 'VastAdParser:: getVastAdDisplayConf: ' + node );
			var $ad = $( node );

			// Set a local pointer to the current sequence:
			var currentAd = { 'id' : $( node ).attr('id') };

			// Set duration
			if( $ad.find('duration') ){
				currentAd.duration = mw.npt2seconds( $ad.find( 'duration' ).text() );
			}

			// Set impression urls
			currentAd.impressions = [];
			$ad.find( 'Impression' ).each( function(na, node){
				// Check if there is lots of impressions or just one:
				if( $(node).find('URL').length ){
					$ad.find('URL').each( function( na, urlNode ){
						currentAd.impressions.push({
							'beaconUrl' : _this.getURLFromNode( urlNode ),
							'idtype' : $( urlNode ).attr('id')
						});
					});
				} else {
					currentAd.impressions.push({
						'beaconUrl' : _this.getURLFromNode( node )
					});
				}
			});

			// Set Non Linear Ads
			currentAd.nonLinear = [];
			$ad.find( 'NonLinearAds NonLinear' ).each( function( na, nonLinearNode ){
				var staticResource = _this.getResourceObject( nonLinearNode );
				if( staticResource ){
					// Add the staticResource to the ad config:
					currentAd.nonLinear.push( staticResource );
				}
			});

			// Set tracking events:
			currentAd.trackingEvents = [];
			// Check for Linear descendant ( double click vast XML has multiple trackingEvents per Linear and non-Linear and
			var selector = 'trackingEvents Tracking';
			if( $ad.find( 'InLine Linear').length ){
				selector = 'InLine Linear ' + selector;
			}
			$ad.find( selector ).each( function( na, trackingNode ){
				currentAd.trackingEvents.push({
					'eventName' : $( trackingNode ).attr('event'),
					'beaconUrl' : _this.getURLFromNode( trackingNode )
				});
			});

			currentAd.videoFiles = [];
			// Set the media file:
			$ad.find('MediaFiles MediaFile').each( function( na, mediaFile ){
				// Add the video source ( if an html5 compatible type )
				var type  = $( mediaFile ).attr('type');
				// Normalize mp4 into h264 format:
				if( type  == 'video/x-mp4' || type == 'video/mp4' ){
					type = 'video/h264';
				}

				if(  type == 'video/h264' || type == 'video/ogg' || type == 'video/webm' ){
					var source = {
							'src' :_this.getURLFromNode( mediaFile ),
							'type' : type
						};
					if( $( mediaFile ).attr('bitrate') ){
						source['data-bandwith']  = $( mediaFile ).attr('bitrate')* 1024;
					}
					if( $( mediaFile ).attr('width') ){
						source['data-width'] =  $( mediaFile ).attr('width');
					}
					if( $( mediaFile ).attr('height') ){
						source['data-height'] =  $( mediaFile ).attr('height');
					}
					// Add the source object:
					currentAd.videoFiles.push( source );
					mw.log( "VastAdParser::add MediaFile:" + _this.getURLFromNode( mediaFile ) );
				}
			});

{'fraction_non_alphanumeric': 0.16142748671222476, 'fraction_numerical': 0.005466970387243736, 'mean_word_length': 2.7634285714285713, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '4255539', 'n_tokens_mistral': 2648, 'n_tokens_neox': 2079, 'n_words': 568}