diff --git a/index.php b/index.php index f378012..747b75e 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,53 @@ $video_url, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HEADER => false, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_USERAGENT => 'okhttp', + CURLOPT_ENCODING => "utf-8", + CURLOPT_AUTOREFERER => false, + CURLOPT_REFERER => 'https://www.tiktok.com/', + CURLOPT_CONNECTTIMEOUT => 30, + CURLOPT_SSL_VERIFYHOST => false, + CURLOPT_SSL_VERIFYPEER => false, + CURLOPT_TIMEOUT => 30, + CURLOPT_MAXREDIRS => 10, + ); + curl_setopt_array( $ch, $options ); + if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { + curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); + } + $data = curl_exec($ch); + $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + if ($geturl === true) + { + return curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); + } + curl_close($ch); + $filename = "user_videos/" . generateRandomString() . ".mp4"; + $d = fopen($filename, "w"); + fwrite($d, $data); + fclose($d); + return $filename; +} + function getContent($url, $geturl = false) { $ch = curl_init(); @@ -138,7 +186,12 @@ function getContent($url, $geturl = false) $videoKey = getKey($contentURL); $cleanVideo = "https://api2-16-h2.musical.ly/aweme/v1/play/?video_id=$videoKey&vr_type=0&is_play_url=1&source=PackSourceEnum_PUBLISH&media_type=4"; $cleanVideo = getContent($cleanVideo, true); - + if (!file_exists("user_videos") && $store_locally){ + mkdir("user_videos"); + } + if ($store_locally){ + $filename = downloadVideo($contentURL); + } ?>