protected function renderInformationVideo() { if (is_null($this->informationVideo)) { $obj = new ThumbnailInformation(); $information = ThumbnailClient::get(sprintf(ThumbnailUrl::URLInfo, $this->code)); $info = array(); parse_str($information, $info); $obj->setAuthor($info['author'])->setTitle($info['title'])->setVideoId($info['video_id'])->setHostLanguage($info['host_language'])->setKeywords($info['keywords'])->setTimestamp((int) $info['timestamp'])->setLengthSeconds((int) $info['length_seconds'])->setViewCount((int) $info['view_count'])->setThumbnail($this->getPictures()); $fmts = array(); foreach ($this->infoVideo($info, 'adaptive_fmts') as $value) { $fmtsObject = new ThumbnailAdaptiveFmts(); $fmtsObject->setUrl($value['url'])->setBitrate($value['bitrate'])->setClen($value['clen'])->setFps(isset($value['fps']) ? $value['fps'] : 0)->setIndex($value['index'])->setInit($value['init'])->setItag($value['itag'])->setLmt($value['lmt'])->setProjectionType($value['projection_type'])->setQualityLabel(isset($value['quality_label']) ? $value['quality_label'] : 0)->setSize(isset($value['size']) ? $value['size'] : 0)->setType($value['type']); $fmts[] = $fmtsObject; } $obj->setAdaptiveFmts(new ThumbnailAdaptiveFmtsCollection($fmts)); $map = array(); foreach ($this->infoVideo($info, 'url_encoded_fmt_stream_map') as $value) { $mapObject = new ThumbnailUrlEncodedFmtStreamMap(); $mapObject->setType($value['type'])->setUrl($value['url'])->setItag($value['itag'])->setFallbackHost($value['fallback_host'])->setQuality($value['quality']); $map[] = $mapObject; } $obj->setUrlEncodedFmtStreamMap(new ThumbnailUrlEncodedFmtStreamMapCollection($map)); $this->informationVideo = $obj; } return $this->informationVideo; }
public function save($path) { return ThumbnailClient::save($this->url, $path, $this->id, $this->code); }