How to get downloadable video url from douyin?
<?php
header("Content-Type: text/html;charset=utf-8");
if(isset($_GET["url"])){
//HTTP headers setting
$hdrs = array(
'http' =>array('header' =>
"Referer: https://v.douyin.com/" .
"User-Agent: Mozilla/5.0 ABCD\r\n"
),
);
//Create requests
$context = stream_context_create($hdrs);
//Parse request get video id
file_get_contents($_GET["url"],0,$context);
$id=$http_response_header[6];
$id=explode("video/",$id);
$id=explode("/?",$id[1]);
$id=$id[0];
//Get video data from api
$url="https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=".$id;
$jsonData=file_get_contents($url,0,$context);
$jsonData=json_decode($jsonData);
//Get watermark play url
$url=$jsonData->item_list[0]->video->play_addr->url_list[0];
//Get watermark video url
$url=str_replace("playwm","play",$url);
//Get non watermark video url
file_get_contents($url,0,$context);
for($i=0;$i<sizeof($http_response_header);$i++){
$url=$http_response_header[$i];
if(substr($url,0,8)=="location"){
$url=$http_response_header[$i];
break;
}
}
$url=str_replace("location: ","",$url);
echo $url;
}