2020-04-12 15:16:10 +03:00
< ? php
2024-04-22 13:21:31 +03:00
// https://github.com/TufayelLUS/TikTok-Video-Downloader-PHP
2023-01-26 15:36:19 +03:00
$store_locally = true ; /* change to false if you don't want to host videos locally */
2020-09-30 16:46:56 +03:00
2023-01-26 15:36:19 +03:00
function generateRandomString ( $length = 10 )
{
2020-09-30 16:46:56 +03:00
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ;
$charactersLength = strlen ( $characters );
$randomString = '' ;
for ( $i = 0 ; $i < $length ; $i ++ ) {
$randomString .= $characters [ rand ( 0 , $charactersLength - 1 )];
}
return $randomString ;
}
function downloadVideo ( $video_url , $geturl = false )
{
2020-10-02 11:44:18 +03:00
$ch = curl_init ();
2020-11-01 13:00:07 +03:00
$headers = array (
'Range: bytes=0-' ,
);
2020-09-30 16:46:56 +03:00
$options = array (
CURLOPT_URL => $video_url ,
CURLOPT_RETURNTRANSFER => true ,
CURLOPT_HEADER => false ,
2020-11-01 13:00:07 +03:00
CURLOPT_HTTPHEADER => $headers ,
2020-09-30 16:46:56 +03:00
CURLOPT_FOLLOWLOCATION => true ,
2020-11-01 13:00:07 +03:00
CURLINFO_HEADER_OUT => true ,
2020-11-14 20:11:29 +03:00
CURLOPT_USERAGENT => 'okhttp' ,
2020-09-30 16:46:56 +03:00
CURLOPT_ENCODING => " utf-8 " ,
2020-11-01 13:00:07 +03:00
CURLOPT_AUTOREFERER => true ,
CURLOPT_COOKIEJAR => 'cookie.txt' ,
2023-01-26 15:36:19 +03:00
CURLOPT_COOKIEFILE => 'cookie.txt' ,
2020-09-30 16:46:56 +03:00
CURLOPT_REFERER => 'https://www.tiktok.com/' ,
CURLOPT_CONNECTTIMEOUT => 30 ,
CURLOPT_SSL_VERIFYHOST => false ,
CURLOPT_SSL_VERIFYPEER => false ,
CURLOPT_TIMEOUT => 30 ,
CURLOPT_MAXREDIRS => 10 ,
);
2023-01-26 15:36:19 +03:00
curl_setopt_array ( $ch , $options );
2020-09-30 16:46:56 +03:00
if ( defined ( 'CURLOPT_IPRESOLVE' ) && defined ( 'CURL_IPRESOLVE_V4' )) {
2023-01-26 15:36:19 +03:00
curl_setopt ( $ch , CURLOPT_IPRESOLVE , CURL_IPRESOLVE_V4 );
2020-09-30 16:46:56 +03:00
}
$data = curl_exec ( $ch );
$httpcode = curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
2023-01-26 15:36:19 +03:00
if ( $geturl === true ) {
2020-09-30 16:46:56 +03:00
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 ;
}
2020-10-02 11:44:18 +03:00
if ( isset ( $_GET [ 'url' ]) && ! empty ( $_GET [ 'url' ])) {
if ( $_SERVER [ 'HTTP_REFERER' ] != " " ) {
$url = $_GET [ 'url' ];
$name = downloadVideo ( $url );
echo $name ;
exit ();
2023-01-26 15:36:19 +03:00
} else {
2020-10-02 11:44:18 +03:00
echo " " ;
exit ();
}
}
2020-07-19 11:18:19 +03:00
function getContent ( $url , $geturl = false )
2023-01-26 15:36:19 +03:00
{
2020-04-12 15:16:10 +03:00
$ch = curl_init ();
$options = array (
CURLOPT_URL => $url ,
CURLOPT_RETURNTRANSFER => true ,
CURLOPT_HEADER => false ,
CURLOPT_FOLLOWLOCATION => true ,
2024-04-22 13:21:31 +03:00
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36' ,
2020-04-12 15:16:10 +03:00
CURLOPT_ENCODING => " utf-8 " ,
2020-09-18 11:12:52 +03:00
CURLOPT_AUTOREFERER => false ,
2020-11-01 13:00:07 +03:00
CURLOPT_COOKIEJAR => 'cookie.txt' ,
2023-01-26 15:36:19 +03:00
CURLOPT_COOKIEFILE => 'cookie.txt' ,
2020-09-18 11:12:52 +03:00
CURLOPT_REFERER => 'https://www.tiktok.com/' ,
2020-04-12 15:16:10 +03:00
CURLOPT_CONNECTTIMEOUT => 30 ,
CURLOPT_SSL_VERIFYHOST => false ,
2020-05-11 19:11:40 +03:00
CURLOPT_SSL_VERIFYPEER => false ,
2020-04-12 15:16:10 +03:00
CURLOPT_TIMEOUT => 30 ,
CURLOPT_MAXREDIRS => 10 ,
);
2023-01-26 15:36:19 +03:00
curl_setopt_array ( $ch , $options );
2020-04-12 15:16:10 +03:00
if ( defined ( 'CURLOPT_IPRESOLVE' ) && defined ( 'CURL_IPRESOLVE_V4' )) {
2023-01-26 15:36:19 +03:00
curl_setopt ( $ch , CURLOPT_IPRESOLVE , CURL_IPRESOLVE_V4 );
2020-04-12 15:16:10 +03:00
}
$data = curl_exec ( $ch );
$httpcode = curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
2023-01-26 15:36:19 +03:00
if ( $geturl === true ) {
2020-07-19 11:18:19 +03:00
return curl_getinfo ( $ch , CURLINFO_EFFECTIVE_URL );
}
2020-04-12 15:16:10 +03:00
curl_close ( $ch );
return strval ( $data );
2023-01-26 15:36:19 +03:00
}
2020-05-11 19:11:40 +03:00
2023-01-26 15:36:19 +03:00
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'
];
2020-05-11 19:11:40 +03:00
$options = array (
CURLOPT_URL => $playable ,
CURLOPT_RETURNTRANSFER => true ,
CURLOPT_HEADER => false ,
CURLOPT_HTTPHEADER => $headers ,
CURLOPT_FOLLOWLOCATION => true ,
CURLOPT_USERAGENT => 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0' ,
CURLOPT_ENCODING => " utf-8 " ,
2020-09-18 11:12:52 +03:00
CURLOPT_AUTOREFERER => false ,
2020-11-01 13:04:40 +03:00
CURLOPT_COOKIEJAR => 'cookie.txt' ,
2023-01-26 15:36:19 +03:00
CURLOPT_COOKIEFILE => 'cookie.txt' ,
2020-09-18 11:12:52 +03:00
CURLOPT_REFERER => 'https://www.tiktok.com/' ,
2020-05-11 19:11:40 +03:00
CURLOPT_CONNECTTIMEOUT => 30 ,
CURLOPT_SSL_VERIFYHOST => false ,
CURLOPT_SSL_VERIFYPEER => false ,
CURLOPT_TIMEOUT => 30 ,
CURLOPT_MAXREDIRS => 10 ,
);
2023-01-26 15:36:19 +03:00
curl_setopt_array ( $ch , $options );
2020-05-11 19:11:40 +03:00
if ( defined ( 'CURLOPT_IPRESOLVE' ) && defined ( 'CURL_IPRESOLVE_V4' )) {
2023-01-26 15:36:19 +03:00
curl_setopt ( $ch , CURLOPT_IPRESOLVE , CURL_IPRESOLVE_V4 );
2020-05-11 19:11:40 +03:00
}
$data = curl_exec ( $ch );
$httpcode = curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
curl_close ( $ch );
$tmp = explode ( " vid: " , $data );
2023-01-26 15:36:19 +03:00
if ( count ( $tmp ) > 1 ) {
$key = trim ( explode ( " % " , $tmp [ 1 ])[ 0 ]);
2024-04-22 13:21:31 +03:00
$key = trim ( explode ( " . " , $key )[ 0 ]);
2023-01-26 15:36:19 +03:00
} else {
$key = " " ;
2020-05-11 19:11:40 +03:00
}
return $key ;
2023-01-26 15:36:19 +03:00
}
function escape_sequence_decode ( $str )
{
// [U+D800 - U+DBFF][U+DC00 - U+DFFF]|[U+0000 - U+FFFF]
$regex = ' / \\\u ([ dD ][ 89 abAB ][ \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 );
}
2020-04-12 15:16:10 +03:00
?>
<! DOCTYPE html >
< html >
2023-01-26 15:36:19 +03:00
2020-04-12 15:16:10 +03:00
< head >
2023-01-26 15:36:19 +03:00
< title > TikTok Video Downloader </ title >
< meta name = " viewport " content = " width=device-width, initial-scale=1, shrink-to-fit=no " >
< link rel = " stylesheet " href = " https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css " integrity = " sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh " crossorigin = " anonymous " >
< script src = " https://code.jquery.com/jquery-3.4.1.min.js " ></ script >
</ script >
< script src = " https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js " integrity = " sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo " crossorigin = " anonymous " ></ script >
< script src = " https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js " integrity = " sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6 " crossorigin = " anonymous " ></ script >
< link href = " https://fonts.googleapis.com/css2?family=Gotu&display=swap " rel = " stylesheet " >
< style type = " text/css " >
html ,
body {
font - family : " Gotu "
}
input {
padding : 5 px ;
border - radius : 10 px ;
border - style : solid ;
border - color : blue ;
transition - duration : 0.5 s ;
width : 80 % ;
}
input : focus {
border - color : skyblue ;
transition - duration : 0.5 s ;
}
</ style >
2020-04-12 15:16:10 +03:00
</ head >
2023-01-26 15:36:19 +03:00
2020-04-12 15:16:10 +03:00
< body class = " bg-light " >
2023-01-26 15:36:19 +03:00
< div class = " text-center p-5 " >
< img src = " data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMjlweCIgaGVpZ2h0PSIzMnB4IiB2aWV3Qm94PSIwIDAgMjkgMzIiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8IS0tIEdlbmVyYXRvcjogU2tldGNoIDU1LjIgKDc4MTgxKSAtIGh0dHBzOi8vc2tldGNoYXBwLmNvbSAtLT4KICAgIDx0aXRsZT7nvJbnu4QgMjwvdGl0bGU+CiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4KICAgIDxnIGlkPSLpobXpnaIxIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj4KICAgICAgICA8ZyBpZD0i57yW57uELTIiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAuOTc5MjM2LCAwLjAwMDAwMCkiIGZpbGwtcnVsZT0ibm9uemVybyI+CiAgICAgICAgICAgIDxwYXRoIGQ9Ik0xMC43OTA3NjQ1LDEyLjMzIEwxMC43OTA3NjQ1LDExLjExIEMxMC4zNjcy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AgICA8cGF0aCBkPSJNMTkuMDIwNzY0NSwyMC41MSBMMTkuM
< h4 >< b > Script last modified :</ b > < span style = " color:#236c82;font-style:italic " >< ? php date_default_timezone_set ( 'UTC' );
echo date ( " F d Y H:i:s A " , filemtime ( __FILE__ )); ?> (UTC)</span> <a href="https://github.com/TufayelLUS/TikTok-Video-Downloader-PHP/commits/master" rel="nofollow" title="Click to view commits history in github" target="_blank">Check Logs</a></h4>
</ div >
< div class = " text-center " >
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 .< br >< br >
< form method = " POST " class = " mt-2 " >
< input type = " text " placeholder = " https://www.tiktok.com/@username/video/1234567890123456789 " class = " mb-3 " name = " tiktok-url " >< br >< br >
< button class = " btn btn-success " type = " submit " > Download </ button >
</ form >
</ div >
< ? php
if ( isset ( $_POST [ 'tiktok-url' ]) && ! empty ( $_POST [ 'tiktok-url' ])) {
$url = trim ( $_POST [ 'tiktok-url' ]);
$resp = getContent ( $url );
$check = explode ( '"downloadAddr":"' , $resp );
if ( count ( $check ) > 1 ) {
$contentURL = explode ( " \" " , $check [ 1 ])[ 0 ];
$contentURL = escape_sequence_decode ( $contentURL );
$thumb = explode ( " \" " , explode ( '"dynamicCover":"' , $resp )[ 1 ])[ 0 ];
$thumb = escape_sequence_decode ( $thumb );
2024-04-22 13:21:31 +03:00
$username = explode ( '"' , explode ( 'uniqueId":"' , $resp )[ 1 ])[ 0 ];
2023-01-26 15:36:19 +03:00
$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 ) {
?>
< script type = " text/javascript " >
$ ( document ) . ready ( function () {
$ ( '#wmarked_link' ) . text ( " Please wait ... " );
$ . get ( './<?php echo basename($_SERVER[' PHP_SELF ']); ?>?url=<?php echo urlencode($contentURL); ?>' ) . done ( function ( data ) {
$ ( '#wmarked_link' ) . removeAttr ( 'disabled' );
$ ( '#wmarked_link' ) . attr ( 'onclick' , 'window.location.href="' + data + '"' );
$ ( '#wmarked_link' ) . text ( " Download Video " );
2020-10-02 11:44:18 +03:00
});
2023-01-26 15:36:19 +03:00
});
</ script >
< ? php
}
?>
< script >
$ ( document ) . ready ( function () {
$ ( 'html, body' ) . animate ({
scrollTop : ( $ ( '#result' ) . offset () . top )
}, 1000 );
});
</ script >
< div class = " border m-3 mb-5 " id = " result " >
< div class = " row m-0 p-2 " >
< div class = " col-sm-5 col-md-5 col-lg-5 text-center " >< img width = " 250px " height = " 250px " src = " <?php echo $thumb ; ?> " ></ div >
< div class = " col-sm-6 col-md-6 col-lg-6 text-center mt-5 " >
< ul style = " list-style: none;padding: 0px " >
< li > a video by < b >@< ? php echo $username ; ?> </b></li>
< li > uploaded on < b >< ? php echo $create_time ; ?> </b></li>
< li >< button id = " wmarked_link " disabled = " disabled " class = " btn btn-primary mt-3 " onclick = " window.location.href='<?php if ( $store_locally ) {
echo $filename ;
} else {
echo $contentURL ;
} ?> '">Download Video</button> <button class="btn btn-info mt-3" onclick="window.location.href='<?php echo $cleanVideo; ?>'">Download Watermark Free!</button></li>
< li >
< div class = " alert alert-primary mb-0 mt-3 " > If the video opens directly , try saving it by pressing CTRL + S or on phone , save from three dots in the bottom left corner </ div >
</ li >
</ ul >
</ div >
</ div >
</ div >
< ? php
} else {
?>
< script >
$ ( document ) . ready ( function () {
$ ( 'html, body' ) . animate ({
scrollTop : ( $ ( '#result' ) . offset () . top )
}, 1000 );
});
</ script >
< div class = " mx-5 px-5 my-3 " id = " result " >
< div class = " alert alert-danger mb-0 " >< b > Please double check your url and try again .</ b ></ div >
</ div >
2020-04-12 15:16:10 +03:00
2023-01-26 15:36:19 +03:00
< ? php
}
}
?>
< div class = " m-5 " >
& nbsp ;
</ div >
2024-04-22 13:21:31 +03:00
< div class = " bg-dark text-white " style = " position: fixed; bottom: 0;width: 100%;padding:15px " > Developed by < a target = " _blank " href = " https://www.github.com/TufayelLUS " > Tufayel Ahmed </ a > < span style = " float: right; " > Copyright & copy ; < ? php echo date ( " Y " ); ?> </span></div>
2020-05-11 19:11:40 +03:00
< script type = " text/javascript " >
2023-01-26 15:36:19 +03:00
window . setInterval ( function () {
2020-05-11 19:11:40 +03:00
if ( $ ( " input[name='tiktok-url'] " ) . attr ( " placeholder " ) == " https://www.tiktok.com/@username/video/1234567890123456789 " ) {
$ ( " input[name='tiktok-url'] " ) . attr ( " placeholder " , " https://vm.tiktok.com/a1b2c3/ " );
2023-01-26 15:36:19 +03:00
} else {
2020-05-11 19:11:40 +03:00
$ ( " input[name='tiktok-url'] " ) . attr ( " placeholder " , " https://www.tiktok.com/@username/video/1234567890123456789 " );
}
}, 3000 );
</ script >
2020-04-12 15:16:10 +03:00
</ body >
2023-01-26 15:36:19 +03:00
2020-04-12 15:16:10 +03:00
</ html >