protected function downloadCaption($captions, $language, $filename)
	{
		if ($language === null) $language = $this->defaultCaptionLanguage;
		if (!array_key_exists($language, $captions))
			$captionData = array_shift($captions);
		else
			$captionData = $captions[$language];

		$captionData = $this->parseCaption($captionData);
		if ($captionData !== null) {

			$captionData = $this->formatCaption($captionData->caption);

			$filename = substr($filename, 0, strrpos($filename, '.')) . '.' . $captionData->extension;
			$path = $this->path . DIRECTORY_SEPARATOR . $filename;

			file_put_contents($path, $captionData->caption);
		}
	}
protected function downloadCaption($captions, $language, $filename)
	{
		if ($language === null) $language = $this->defaultCaptionLanguage;
		if (!array_key_exists($language, $captions))
			$captionData = array_shift($captions);
		else
			$captionData = $captions[$language];

		$captionData = $this->parseCaption($captionData);
		if ($captionData !== null) {

			$captionData = $this->formatCaption($captionData->caption);

			$filename = substr($filename, 0, strrpos($filename, '.')) . '.' . $captionData->extension;
			$path = $this->path . DIRECTORY_SEPARATOR . $filename;

			file_put_contents($path, $captionData->caption);
		}
	}
protected function downloadCaption ( $ captions , $ language , $ filename ) { if ( $ language === null ) $ language = $ this -> defaultCaptionLanguage ; if ( ! array_key_exists ( $ language , $ captions ) ) $ captionData = array_shift ( $ captions ) ; else $ captionData = $ captions [ $ language ] ; $ captionData = $ this -> parseCaption ( $ captionData ) ; if ( $ captionData !== null ) { $ captionData = $ this -> formatCaption ( $ captionData -> caption ) ; $ filename = substr ( $ filename , 0 , strrpos ( $ filename , '.' ) ) . '.' . $ captionData -> extension ; $ path = $ this -> path . DIRECTORY_SEPARATOR . $ filename ; file_put_contents ( $ path , $ captionData -> caption ) ; } }
Downloads caption of the video in selected language

@param  array $captions Captions data of video
@param  string $language User selected language
@param  string $filename Caption file name
Downloads caption of the video in selected language