Public: Convert video URL to a valid video URL
342702
public function getVideo()
    {
        // This function is based on code by Wouter Sioen released under the MIT license
        // see woutersioen/sir-trevor-php
        // Regexps from http://stackoverflow.com/questions/10488943/easy-way-to-get-vimeo-id-from-a-vimeo-url
        // and http://stackoverflow.com/questions/3452546/javascript-regex-how-to-get-youtube-video-id-from-url
        if (preg_match('/.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#\&\?]*).*/', $this->getVideoUrl(), $matches)) {
            $data = array(
                'source' => 'youtube',
                'remote_id' => $matches[1]
            );
        } elseif (preg_match('/(?:https?:\/\/)?(?:www\.)?(?:player\.)?vimeo\.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/', $this->getVideoUrl(), $matches)) {
            $data = array(
                'source' => 'vimeo',
                'remote_id' => $matches[2]
            );
        } else {
            throw new \FelixOnline\Exceptions\InternalException('The specified video URL is not valid');
        }

        if ($data['source'] == 'youtube') {
            $html = '<iframe src="//www.youtube.com/embed/' . $data['remote_id'] . '?rel=0" ';
            $html .= 'frameborder="0" allowfullscreen></iframe>' . "\n";
        } else {
            $html = '<iframe src="//player.vimeo.com/video/' . $data['remote_id'];
            $html .= '?title=0&amp;byline=0" frameborder="0"></iframe>' . "\n";
        }

        return $html;
    }
649197
public static function preprocess($url_parsed) {

        // new links
        if (preg_match('/^\/video\/(\d+)\/([^\/]+)$/', $url_parsed['path'], $matches) == 1) {
            return array(
                'version' => 2,
                'vid' => $matches[1],
                'name' => $matches[2],
            );
        }

        // old links
        if (preg_match('/^\/video\:(\d+)$/', $url_parsed['path'], $matches) == 1) {
            return array(
                'version' => 1,
                'vid' => $matches[1],
            );
        }
        if (preg_match('/^\/moogaloop\/moogaloop\.swf$/', $url_parsed['path'], $matches) == 1) {
            parse_str($url_parsed["query"], $args);
            return array(
                'version' => 1,
                'vid' => $args['clip_id'],
            );
        }

        return FALSE;
    }
1184695
function _convertUrlsToLinks(str) {
    return str.replace(URL_REG_EXP, function(match, url) {
      var punctuation = (url.match(TRAILING_CHAR_REG_EXP) || [])[1] || "",
          opening     = BRACKETS[punctuation];
      url = url.replace(TRAILING_CHAR_REG_EXP, "");

      if (url.split(opening).length > url.split(punctuation).length) {
        url = url + punctuation;
        punctuation = "";
      }
      var realUrl    = url,
          displayUrl = url;
      if (url.length > MAX_DISPLAY_LENGTH) {
        displayUrl = displayUrl.substr(0, MAX_DISPLAY_LENGTH) + "...";
      }
      // Add http prefix if necessary
      if (realUrl.substr(0, 4) === "www.") {
        realUrl = "http://" + realUrl;
      }

      return '<a href="' + realUrl + '">' + displayUrl + '</a>' + punctuation;
    });
  }
483454
def encode_example(self, video_or_path_or_fobj):
    """"""
    if isinstance(video_or_path_or_fobj, six.string_types):
      if not os.path.isfile(video_or_path_or_fobj):
        _, video_temp_path = tempfile.mkstemp()
        try:
          tf.gfile.Copy(video_or_path_or_fobj, video_temp_path, overwrite=True)
          encoded_video = self._ffmpeg_decode(video_temp_path)
        finally:
          os.unlink(video_temp_path)
      else:
        encoded_video = self._ffmpeg_decode(video_or_path_or_fobj)
    elif hasattr(video_or_path_or_fobj, 'read'):
      encoded_video = self._ffmpeg_decode(video_or_path_or_fobj)
    else:
      encoded_video = video_or_path_or_fobj
    return super(Video, self).encode_example(encoded_video)
256311
function WhammyVideo(duration, quality) {
        this.frames = [];
        if (!duration) {
            duration = 1;
        }
        this.duration = 1000 / duration;
        this.quality = quality || 0.8;
    }
1372425
function parse_youtube(url_path, $) {
  // Durations are ISO 8601 format: "PT48M42S"
  const duration_regex = /^PT(?:(\d+)H)?(?:(\d+)M)?(\d+)S$/;

  if (url_path.match("^\\/watch") === null) {
    return parse_generic(url_path, $);
  }

  // TODO: only do this for paths that make sense
  const title = $("meta[itemprop=name]").attr("content");
  const views = $("#watch7-views-info > div.watch-view-count").text().split(" ")[0] || 0;
  let likes = $("#watch-header .like-button-renderer span.yt-uix-button-content").first().text().replace(/[\s,]/g, "") || 0;
  let dislikes = $("#watch-header .like-button-renderer span.yt-uix-button-content").get(3);
  dislikes = $(dislikes).text().replace(/[\s,]/g, "") || 0;
  likes = parseInt(likes, 10);
  dislikes = parseInt(dislikes, 10);
  const rating = Math.round(100 * likes / (likes + dislikes));
  let duration = $("meta[itemprop=duration]").attr("content");
  let matches = duration_regex.exec(duration);
  if (matches) {
    matches = {
      hours: parseInt(matches[1], 10),
      minutes: parseInt(matches[2], 10),
      seconds: parseInt(matches[3], 10),
    };
    // Youtube often sets hours to zero and minutes to >= 60
    if (matches.minutes >= 60) {
      matches.hours = Math.floor(matches.minutes / 60);
      matches.minutes = matches.minutes % 60;
    }
    if (matches.minutes < 10) {
      matches.minutes = "0" + matches.minutes;
    }
    if (matches.seconds < 10) {
      matches.seconds = "0" + matches.seconds;
    }
    duration = util.format("%s:%s", matches.minutes, matches.seconds);
    if (matches.hours) {
      duration = util.format("%s:%s", matches.hours, duration);
    }
  } else {
    duration = "";
  }
  return util.format("%s %s %s views %s%% like", title, duration, views, rating);
}
1078120
def video(request, obj_id):
    """"""
    obj = Video.objects.get(pk=obj_id)
    if request.method == 'POST':
        return post(request, obj)
    elif request.method == 'PUT':
        getPutData(request)
        return put(request, obj)
    elif request.method == 'DELETE':
        getPutData(request)
        return delete(request, obj)
335971
function scrapVideo(window){
   var $ = window.$;
   var url = window.location.href;
   var thumbs = [];

   // Open Graph protocol by Facebook: <meta property="og:video" content="(*)"/>
   $('meta').each(function(){
      var property = $(this).attr('property');
      var content = $(this).attr('content');
      if(property === 'og:video' && content){
         thumbs.push(utils.toURL(content));
      }
   });

   $('video, embed').each(function(){
      var src = $(this).attr('src');
      if(src) thumbs.push(utils.toURL(src,url));
   });

   return thumbs;
}
544638
function (result) {
            if (result.stat('googFrameRateSent')) {
              currentStats.videoSentBytes = Number(result.stat('bytesSent'));
              currentStats.videoSentPackets = Number(result.stat('packetsSent'));
              currentStats.videoSentPacketsLost = Number(result.stat('packetsLost'));
              currentStats.videoRtt = Number(result.stat('googRtt'));
              currentStats.videoFrameRate = Number(result.stat('googFrameRateInput'));
              currentStats.videoWidth = Number(result.stat('googFrameWidthSent'));
              currentStats.videoHeight = Number(result.stat('googFrameHeightSent'));
              currentStats.videoCodec = result.stat('googCodecName');
            } else if (result.stat('googFrameRateReceived')) {
              currentStats.videoRecvBytes = Number(result.stat('bytesReceived'));
              currentStats.videoRecvPackets = Number(result.stat('packetsReceived'));
              currentStats.videoRecvPacketsLost = Number(result.stat('packetsLost'));
              currentStats.videoFrameRate = Number(result.stat('googFrameRateOutput'));
              currentStats.videoWidth = Number(result.stat('googFrameWidthReceived'));
              currentStats.videoHeight = Number(result.stat('googFrameHeightReceived'));
              currentStats.videoCodec = result.stat('googCodecName');
            }
            return null;
          }
659401
function( url, html )
            {
                url = $.trim(url||'');
                html = $.trim(html||'');
                var website_url = false;
                if( url.length && ! html.length )
                    website_url = url;
                else if( html.indexOf('<') == -1 && html.indexOf('>') == -1 &&
                         html.match(/^(?:https?:\/)?\/?(?:[^:\/\s]+)(?:(?:\/\w+)*\/)(?:[\w\-\.]+[^#?\s]+)(?:.*)?(?:#[\w\-]+)?$/) )
                    website_url = html;
                if( website_url && video_from_url )
                    html = video_from_url( website_url ) || '';
                if( ! html.length && website_url )
                    html = '<video src="' + html_encode(website_url) + '">';
                wysiwygeditor.insertHTML( html ).closePopup().collapseSelection();
            }
503286
function(validBidRequests, bidderRequest) {
    const loc = utils.getTopWindowLocation();
    const page = loc.href;
    const isPageSecure = (loc.protocol === 'https:') ? 1 : 0;
    let siteId = '';
    let requestId = '';
    let pubcid = null;

    const conversantImps = validBidRequests.map(function(bid) {
      const bidfloor = utils.getBidIdParameter('bidfloor', bid.params);
      const secure = isPageSecure || (utils.getBidIdParameter('secure', bid.params) ? 1 : 0);

      siteId = utils.getBidIdParameter('site_id', bid.params);
      requestId = bid.auctionId;

      const imp = {
        id: bid.bidId,
        secure: secure,
        bidfloor: bidfloor || 0,
        displaymanager: 'Prebid.js',
        displaymanagerver: VERSION
      };

      copyOptProperty(bid.params.tag_id, imp, 'tagid');

      if (isVideoRequest(bid)) {
        const videoData = utils.deepAccess(bid, 'mediaTypes.video') || {};
        const format = convertSizes(videoData.playerSize || bid.sizes);
        const video = {};

        if (format && format[0]) {
          copyOptProperty(format[0].w, video, 'w');
          copyOptProperty(format[0].h, video, 'h');
        }

        copyOptProperty(bid.params.position, video, 'pos');
        copyOptProperty(bid.params.mimes || videoData.mimes, video, 'mimes');
        copyOptProperty(bid.params.maxduration, video, 'maxduration');
        copyOptProperty(bid.params.protocols || videoData.protocols, video, 'protocols');
        copyOptProperty(bid.params.api || videoData.api, video, 'api');

        imp.video = video;
      } else {
        const bannerData = utils.deepAccess(bid, 'mediaTypes.banner') || {};
        const format = convertSizes(bannerData.sizes || bid.sizes);
        const banner = {format: format};

        copyOptProperty(bid.params.position, banner, 'pos');

        imp.banner = banner;
      }

      if (bid.userId && bid.userId.pubcid) {
        pubcid = bid.userId.pubcid;
      } else if (bid.crumbs && bid.crumbs.pubcid) {
        pubcid = bid.crumbs.pubcid;
      }

      return imp;
    });

    const payload = {
      id: requestId,
      imp: conversantImps,
      site: {
        id: siteId,
        mobile: document.querySelector('meta[name="viewport"][content*="width=device-width"]') !== null ? 1 : 0,
        page: page
      },
      device: getDevice(),
      at: 1
    };

    let userExt = {};

    // Add GDPR flag and consent string
    if (bidderRequest && bidderRequest.gdprConsent) {
      userExt.consent = bidderRequest.gdprConsent.consentString;

      if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') {
        payload.regs = {
          ext: {
            gdpr: (bidderRequest.gdprConsent.gdprApplies ? 1 : 0)
          }
        };
      }
    }

    // Add common id if available
    if (pubcid) {
      userExt.fpc = pubcid;
    }

    // Only add the user object if it's not empty
    if (!utils.isEmpty(userExt)) {
      payload.user = {ext: userExt};
    }

    return {
      method: 'POST',
      url: URL,
      data: payload,
    };
  }
51604
def get_api_url(self):
        
        url = getattr(settings, 'VIDEOHUB_API_URL', None)
        # Support alternate setting (used by most client projects)
        if not url:
            url = getattr(settings, 'VIDEOHUB_API_BASE_URL', None)
            if url:
                url = url.rstrip('/') + '/videos/{}'
        if not url:
            url = self.DEFAULT_VIDEOHUB_API_URL
        return url.format(self.id)
64493
def _get_remote_video_url(self, remote_node, session_id):
        
        url = '{}/video'.format(self._get_remote_node_url(remote_node))
        timeout = time.time() + 5  # 5 seconds from now

        # Requests videos list until timeout or the video url is found
        video_url = None
        while time.time() < timeout:
            response = requests.get(url).json()
            try:
                video_url = response['available_videos'][session_id]['download_url']
                break
            except KeyError:
                time.sleep(1)
        return video_url
908386
def upload_from_url(self, url):
        
        self.check_token()
        
        params = {'fetchUrl': url}
        r = requests.get(FETCH_URL_ENDPOINT, params=params)

        if r.status_code != 200:
            raise GfycatClientError('Error fetching the URL', r.status_code)

        response = r.json()
        if 'error' in response:
            raise GfycatClientError(response['error'])

        return response
797527
def _url(self, url, file_upload=False):
        

        host = self.api_url
        if file_upload:
            host = self.uploads_api_url

        protocol = 'https' if self.https else 'http'
        if url.endswith('/'):
            url = url[:-1]
        return '{0}://{1}/{2}'.format(
            protocol,
            host,
            url
        )
1325698
function getSpecLink(v_info,str_map,adp_map){

	var links = [];

	if(v_info.dashmpd){

		var specurl = decodeURIComponent(v_info.dashmpd);

		// remove noise
		var q = specurl.replace(/https?:\/\/manifest.googlevideo.com\/api\/manifest\/dash\//, '');

		// prepare to format
		var sq =  q.split('/'),
			stp = [];

		// format key=value 
		for (var i = 0; i < sq.length; i+=2) {
			// if(sq[i + 1].indexOf('%')!==-1)
			// 	sq[i + 1] = decodeURIComponent(sq[i + 1]);
			
			if(sq[i]=='sig') sq[i] = "signature";
			
			if(sq[i]=='s'){
				sq[i] = "signature";
				sq[i + 1] = decodeURIComponent(sq[i + 1]);
			}
			stp.push(sq[i]+'='+sq[i + 1]);
		}

		// rebulid url
		q = stp.join('&');

		// if loss params
		if(q.toLowerCase().indexOf('ratebypass')===-1) q+='&ratebypass=yes';

		// get base url 
		var base_url = "";
		for (var i = 0; i < str_map.length; i++) {
			var sp_url = str_map[i].url.split('?');
			if(sp_url[0]){
				base_url = sp_url[0];
				break;
			}
		}
		// get str, adp map's  Quality params
		var str_fmt = [], adp_fmt = [];
		for (var i = 0; i < str_map.length; i++) str_fmt[str_map[i].itag] = true;
		for (var i = 0; i < adp_map.length; i++) adp_fmt[adp_map[i].itag] = true;
		
		
		// supplement new link
		if(adp_fmt[135] && str_fmt[35]=== void 0){
			links.push({
				itag : 35,
				url : base_url+"?"+q+"&itag=35"
			});
		if((adp_fmt[137]||adp_fmt[264]) && str_fmt[37]=== void 0)
			links.push({
				itag : 37,
				url : base_url+"?"+q+"&itag=37"
			});
		if(adp_fmt[138] && str_fmt[38]=== void 0)
			links.push({
				itag : 38,
				url : base_url+"?"+q+"&itag=38"
			});
		}
	}
	return links;
}
47503
def video(query, opts = {})
      invoke 'Video',
        query,
        opts,
        passthrough_opts: %i(filters sort),
        enum_opt_to_module: {filters: VideoFilter, sort: VideoSort},
        param_name_replacements: {filters: 'VideoFilters', sort: 'VideoSortBy'}
    end