Download a video from the remote node

        :param video_url: video url
        :param video_name: video name
424897
def _download_video(self, video_url, video_name):
        
        filename = '{0:0=2d}_{1}'.format(DriverWrappersPool.videos_number, video_name)
        filename = '{}.mp4'.format(get_valid_filename(filename))
        filepath = os.path.join(DriverWrappersPool.videos_directory, filename)
        if not os.path.exists(DriverWrappersPool.videos_directory):
            os.makedirs(DriverWrappersPool.videos_directory)
        response = requests.get(video_url)
        open(filepath, 'wb').write(response.content)
        self.logger.info("Video saved in '%s'", filepath)
        DriverWrappersPool.videos_number += 1
1188379
def download(self, local, remote):
        
        self.sync(RemoteFile(remote, self.api), LocalFile(local))
1135665
def activate(video_id, _connection=None):
        
        c = _connection
        if not c:
            c = connection.APIConnection()
        data = c.post('update_video', video={
            'id': video_id,
            'itemState': enums.ItemStateEnum.ACTIVE})
        return Video(data=data, _connection=c)
995934
def download(url, localFileName=None, localDirName=None):
    
    localName = url2name(url)
    req = Request(url)
    r = urlopen(req)
    if r.info().has_key('Content-Disposition'):
        # If the response has Content-Disposition, we take file name from it
        localName = r.info()['Content-Disposition'].split('filename=')
        if len(localName) > 1:
            localName = localName[1]
            if localName[0] == '"' or localName[0] == "'":
                localName = localName[1:-1]
        else:
            localName = url2name(r.url)
    elif r.url != url:
        # if we were redirected, the real file name we take from the final URL
        localName = url2name(r.url)
    if localFileName:
        # we can force to save the file as specified name
        localName = localFileName
    if localDirName:
        # we can also put it in some custom directory
        if not os.path.exists(localDirName):
            os.makedirs(localDirName)
        localName = os.path.join(localDirName, localName)

    f = open(localName, 'wb')
    f.write(r.read())
    f.close()
878584
def _DownloadUrl(self, url, dest_dir):
    
    dest_file = tempfile.NamedTemporaryFile(dir=dest_dir, delete=False)
    dest_file.close()
    dest = dest_file.name

    self.logger.info('Downloading url from %s to %s.', url, dest)
    try:
      urlretrieve.urlretrieve(url, dest)
      return dest
    except (httpclient.HTTPException, socket.error, urlerror.URLError) as e:
      self.logger.warning('Could not download %s. %s.', url, str(e))
    except Exception as e:
      self.logger.warning('Exception downloading %s. %s.', url, str(e))
    return None
526147
def download_object(self, object_name):
        
        return self._client.download_object(
            self._instance, self.name, object_name)
571179
def video(id, factory_id, opts = {})
      data, _status_code, _headers = video_with_http_info(id, factory_id, opts)
      return data
    end
966556
def download_file(self, url):
        
        response = requests.get(url, stream=True)
        response.raise_for_status()
        return (int(response.headers.get('content-length', 0)), response)
50957
def download(self,
                 url,
                 dest_path=None):
        
        if os.path.exists(dest_path):
            os.remove(dest_path)

        resp = get(url, stream=True)
        size = int(resp.headers.get("content-length"))
        label = "Downloading {filename} ({size:.2f}MB)".format(
            filename=os.path.basename(dest_path),
            size=size / float(self.chunk_size) / self.chunk_size
        )

        with open_file(dest_path, 'wb') as file:
            content_iter = resp.iter_content(chunk_size=self.chunk_size)
            with progressbar(content_iter,
                             length=size / self.chunk_size,
                             label=label) as bar:
                for chunk in bar:
                    if chunk:
                        file.write(chunk)
                        file.flush()
1111631
def attach_video(self, video: String, caption: String = None, width: Integer = None,
                     height: Integer = None, duration: Integer = None):
        
        self.media.attach_video(video, caption, width=width, height=height, duration=duration)
        return self
683029
function _buildVideo(videoDescriptor) {
		this.url = videoDescriptor.url;
		this.appData = videoDescriptor.appData;
		descriptor = videoDescriptor;
	}
834060
def _load_video(video_filename):
    """"""
    video_filename = str(video_filename)
    print("Loading " + video_filename)
    if not os.path.isfile(video_filename):
        raise Exception("File Not Found: %s" % video_filename)
    # noinspection PyArgumentList
    capture = cv2.VideoCapture(video_filename)
    frame_count = int(capture.get(cv2.CAP_PROP_FRAME_COUNT))
    width, height = get_capture_dimensions(capture)
    fps = int(capture.get(cv2.CAP_PROP_FPS))
    x = 0
    vid_frames = numpy.zeros((frame_count, height, width, 3), dtype='uint8')
    while capture.isOpened():
        ret, frame = capture.read()
        if not ret:
            break

        vid_frames[x] = frame
        x += 1
    capture.release()

    return vid_frames, fps
519320
def request_videos(blink, time=None, page=0):
    
    timestamp = get_time(time)
    url = "{}/api/v2/videos/changed?since={}&page={}".format(
        blink.urls.base_url, timestamp, page)
    return http_get(blink, url)
938846
def is_remote_video_enabled(self, remote_node):
        
        enabled = False
        if remote_node:
            url = '{}/config'.format(self._get_remote_node_url(remote_node))
            try:
                response = requests.get(url, timeout=5).json()
                record_videos = response['config_runtime']['theConfigMap']['video_recording_options'][
                    'record_test_videos']
            except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout, KeyError):
                record_videos = 'false'
            if record_videos == 'true':
                # Wait to the video recorder start
                time.sleep(1)
                enabled = True
        return enabled
1090011
def download_video_no_cache(self):
        
        video_url = self.presentation.metadata['video_url']
        video_path = self.presentation.metadata['video_path']

        # After a while, when downloading a long video (> 1h), the RTMP server seems to reset the connection (rtmpdump
        # returns exit code 2). The only way to get the full stream is to resume the download.
        resume_download = True
        while resume_download:
            try:
                cmd = [self.rtmpdump, '-q', '-e', '-r', video_url, '-y', video_path, "-o", self._video_path]
                subprocess.check_output(cmd, stderr=subprocess.STDOUT)
                resume_download = False
            except subprocess.CalledProcessError as e:
                if e.returncode != 2:
                    try:
                        os.unlink(self._video_path)
                    except OSError:
                        pass

                    raise client.DownloadError("Failed to download video at %s: rtmpdump exited with %s.\n\tOutput:\n%s"
                                           % (video_url, e.returncode, e.output))

        return self._video_path
1081604
def download(url, filename=None):
	
	# requirements os, shutil, urllib.parse, urllib.request
	if not filename:
		url_parts = urllib.parse.urlparse(url)
		filename = os.path.basename(url_parts.path)
	url_h = urllib.request.urlopen(url)
	with open(filename, 'wb') as file_h:
		shutil.copyfileobj(url_h, file_h)
	url_h.close()
	return
689038
def mirror_video(self, is_mirror, callback=None):
        '''
        
        '''
        params = {'isMirror': is_mirror}
        return self.execute_command('mirrorVideo', params, callback=callback)