protected function downloadVideo($itag=null, $resume=false, $caption=false)
	{
		if ($itag) {
			foreach ($this->videoInfo->full_formats as $video) {
				if ($video->itag == $itag) {
					try {
						$this->downloadFull($video->url, $video->filename, $resume);
						$this->finalize($video->filename, $caption);
					} catch (YoutubeException $e) {
						throw $e;
					}
					return;
				}
			}

			foreach ($this->videoInfo->adaptive_formats as $video) {
				if ($video->itag == $itag) {
					try {
						$this->downloadAdaptive($video->url, $video->filename, $video->clen, $resume);
					} catch (YoutubeException $e) {
						throw $e;
					}
					$this->finalize($video->filename, $caption);
					return;
				}
			}
		}

		if (count($this->videoInfo->full_formats) === 0) {
			if (count($this->videoInfo->adaptive_formats) === 0)
				throw new YoutubeException('There is no format for download', 32);
			else {
				$video = $this->videoInfo->adaptive_formats[0];
				try {
					$this->downloadAdaptive($video->url, $video->filename, $video->clen, $resume);
					$this->finalize($video->filename, $caption);
				} catch (YoutubeException $e) {
					throw $e;
				}

			}
		}

		$video = $this->videoInfo->full_formats[0];
		try {
			$this->downloadFull($video->url, $video->filename, $resume);
			$this->finalize($video->filename, $caption);
		} catch (YoutubeException $e) {
			throw $e;
		}
	}