diff --git a/index.php b/index.php index 698c39e..5dd99f0 100644 --- a/index.php +++ b/index.php @@ -1,8 +1,9 @@ "utf-8", CURLOPT_AUTOREFERER => true, CURLOPT_COOKIEJAR => 'cookie.txt', - CURLOPT_COOKIEFILE => 'cookie.txt', + CURLOPT_COOKIEFILE => 'cookie.txt', CURLOPT_REFERER => 'https://www.tiktok.com/', CURLOPT_CONNECTTIMEOUT => 30, CURLOPT_SSL_VERIFYHOST => false, @@ -37,14 +38,13 @@ function downloadVideo($video_url, $geturl = false) CURLOPT_TIMEOUT => 30, CURLOPT_MAXREDIRS => 10, ); - curl_setopt_array( $ch, $options ); + curl_setopt_array($ch, $options); if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { - curl_setopt($ch, CURLOPT_IPRESOLVE, 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) - { + if ($geturl === true) { return curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); } curl_close($ch); @@ -61,16 +61,14 @@ if (isset($_GET['url']) && !empty($_GET['url'])) { $name = downloadVideo($url); echo $name; exit(); - } - else - { + } else { echo ""; exit(); } } function getContent($url, $geturl = false) - { +{ $ch = curl_init(); $options = array( CURLOPT_URL => $url, @@ -81,7 +79,7 @@ function getContent($url, $geturl = false) CURLOPT_ENCODING => "utf-8", CURLOPT_AUTOREFERER => false, CURLOPT_COOKIEJAR => 'cookie.txt', - CURLOPT_COOKIEFILE => 'cookie.txt', + CURLOPT_COOKIEFILE => 'cookie.txt', CURLOPT_REFERER => 'https://www.tiktok.com/', CURLOPT_CONNECTTIMEOUT => 30, CURLOPT_SSL_VERIFYHOST => false, @@ -89,29 +87,28 @@ function getContent($url, $geturl = false) CURLOPT_TIMEOUT => 30, CURLOPT_MAXREDIRS => 10, ); - curl_setopt_array( $ch, $options ); + curl_setopt_array($ch, $options); if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { - curl_setopt($ch, CURLOPT_IPRESOLVE, 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) - { + if ($geturl === true) { return curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); } curl_close($ch); return strval($data); - } +} - function getKey($playable) - { - $ch = curl_init(); - $headers = [ - 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', - 'Accept-Encoding: gzip, deflate, br', - 'Accept-Language: en-US,en;q=0.9', - 'Range: bytes=0-200000' - ]; +function getKey($playable) +{ + $ch = curl_init(); + $headers = [ + 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', + 'Accept-Encoding: gzip, deflate, br', + 'Accept-Language: en-US,en;q=0.9', + 'Range: bytes=0-200000' + ]; $options = array( CURLOPT_URL => $playable, @@ -123,7 +120,7 @@ function getContent($url, $geturl = false) CURLOPT_ENCODING => "utf-8", CURLOPT_AUTOREFERER => false, CURLOPT_COOKIEJAR => 'cookie.txt', - CURLOPT_COOKIEFILE => 'cookie.txt', + CURLOPT_COOKIEFILE => 'cookie.txt', CURLOPT_REFERER => 'https://www.tiktok.com/', CURLOPT_CONNECTTIMEOUT => 30, CURLOPT_SSL_VERIFYHOST => false, @@ -131,161 +128,204 @@ function getContent($url, $geturl = false) CURLOPT_TIMEOUT => 30, CURLOPT_MAXREDIRS => 10, ); - curl_setopt_array( $ch, $options ); + curl_setopt_array($ch, $options); if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { - curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); + curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); } $data = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); $tmp = explode("vid:", $data); - if(count($tmp) > 1){ - $key = trim(explode("%", $tmp[1])[0]); - } - else - { - $key = ""; + if (count($tmp) > 1) { + $key = trim(explode("%", $tmp[1])[0]); + } else { + $key = ""; } return $key; - } +} +function escape_sequence_decode($str) +{ + + // [U+D800 - U+DBFF][U+DC00 - U+DFFF]|[U+0000 - U+FFFF] + $regex = '/\\\u([dD][89abAB][\da-fA-F]{2})\\\u([dD][c-fC-F][\da-fA-F]{2}) + |\\\u([\da-fA-F]{4})/sx'; + + return preg_replace_callback($regex, function ($matches) { + + if (isset($matches[3])) { + $cp = hexdec($matches[3]); + } else { + $lead = hexdec($matches[1]); + $trail = hexdec($matches[2]); + + // http://unicode.org/faq/utf_bom.html#utf16-4 + $cp = ($lead << 10) + $trail + 0x10000 - (0xD800 << 10) - 0xDC00; + } + + // https://tools.ietf.org/html/rfc3629#section-3 + // Characters between U+D800 and U+DFFF are not allowed in UTF-8 + if ($cp > 0xD7FF && 0xE000 > $cp) { + $cp = 0xFFFD; + } + + // https://github.com/php/php-src/blob/php-5.6.4/ext/standard/html.c#L471 + // php_utf32_utf8(unsigned char *buf, unsigned k) + + if ($cp < 0x80) { + return chr($cp); + } else if ($cp < 0xA0) { + return chr(0xC0 | $cp >> 6) . chr(0x80 | $cp & 0x3F); + } + + return html_entity_decode('&#' . $cp . ';'); + }, $str); +} ?> - - TikTok Video Downloader - - - - - - - - - -
- -

Download TikTok video easily!

-

Script last modified: (UTC) Check Logs

- -
-
- Paste a video url below and press "Download". Now scroll down to "Download Video" button or "Download Watermark Free!" button and press to initiate the download process.

-
-

- -
-
- 1){ - $contentURL = explode("\"",$check[1])[0]; - $contentURL = str_replace("\\u0026", "&", $contentURL); - $contentURL = str_replace("\\u002F", "/", $contentURL); - $thumb = explode("\"",explode('og:image" content="', $resp)[1])[0]; - $username = explode('"',explode('"uniqueId":"', $resp)[1])[0]; - $create_time = explode('"', explode('"createTime":"', $resp)[1])[0]; - $dt = new DateTime("@$create_time"); - $create_time = $dt->format("d M Y H:i:s A"); - $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){ - ?> - - - -
-

Bot/Scraper Development Services: DeveloperHired.com
-
-
-
    -
  • a video by @
  • -
  • uploaded on
  • -
  • -
  • If the video opens directly, try saving it by pressing CTRL+S or on phone, save from three dots in the bottom left corner
  • -
-
-
- - -
-

Bot/Scraper Development Services: We-Can-Solve.com
-
Please double check your url and try again.
-
- -
-   -
-
Developed by tufayel.rocks Copyright ©
+ + TikTok Video Downloader + + + + + + + + + + + +
+ +

Download TikTok video easily!

+

Script last modified: (UTC) Check Logs

+ +
+
+ Paste a video url below and press "Download". Now scroll down to "Download Video" button or "Download Watermark Free!" button and press to initiate the download process.

+
+

+ +
+
+ 1) { + $contentURL = explode("\"", $check[1])[0]; + $contentURL = escape_sequence_decode($contentURL); + $thumb = explode("\"", explode('"dynamicCover":"', $resp)[1])[0]; + $thumb = escape_sequence_decode($thumb); + $username = explode('/', explode('rel="canonical" href="https://www.tiktok.com/@', $resp)[1])[0]; + $create_time = explode('"', explode('"createTime":"', $resp)[1])[0]; + $dt = new DateTime("@$create_time"); + $create_time = $dt->format("d M Y H:i:s A"); + $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) { + ?> + + + +
+

Bot/Scraper Development Services: We-Can-Solve.com
+
+
+
+
    +
  • a video by @
  • +
  • uploaded on
  • +
  • +
  • +
    If the video opens directly, try saving it by pressing CTRL+S or on phone, save from three dots in the bottom left corner
    +
  • +
+
+
+
+ + +
+

Bot/Scraper Development Services: DeveloperHired.com
+
Please double check your url and try again.
+
+ + +
+   +
+
Developed by tufayel.rocks Copyright ©
+