getEncoderURL() . "getImageMP4/" . base64_encode($url) . "/webp/{$duration}"; $image = url_get_contents($url); file_put_contents($destination, $image); } } else { echo "\nVideo URL empty"; ob_flush(); } echo "\nGet done"; ob_flush(); } else { echo "\nFile exists: " . $value['title']. " {$destination}"; ob_flush(); } echo "\nFinish: " . $value['title']; echo "\n******\n"; ob_flush(); } function getFirstVideoURL($videoFileName) { $types = array('', '_Low', '_SD', '_HD'); $videosList = getVideosURL($videoFileName); if (!empty($videosList['m3u8']["url"])) { return $videosList['m3u8']["url"]; } foreach ($types as $value) { if (!empty($videosList['mp4' . $value]["url"])) { return $videosList['mp4' . $value]["url"]; } else if (!empty($videosList['webm' . $value]["url"])) { return $videosList['webm' . $value]["url"]; } } return false; } function getFirstVideoPath($videoFileName) { $types = array('', '_Low', '_SD', '_HD'); $videosList = getVideosURL($videoFileName); if (!empty($videosList['m3u8']["path"])) { return $videosList['m3u8']["path"]; } foreach ($types as $value) { if (!empty($videosList['mp4' . $value]["path"])) { return $videosList['mp4' . $value]["path"]; } else if (!empty($videosList['webm' . $value]["path"])) { return $videosList['webm' . $value]["path"]; } } return false; }