uniapp开发app框架在提升开发效率中的独特优势与应用探索
1129
2022-09-02
用PHP如何实现解析抖音无水印视频(php仿抖音短视频源码)
很多时候你在douyin里看到了一个短视频,想复制下来自己编辑文字来发布,可是视频里的水印却是原者的。这个时候你想把水印去掉,你要如何做呢?这里提供PHP实现去除水印的主要方法,其实很简单。
使用方法:
在php后加上 ?url= 抖音的url 。
点击跳转后的网页一个是标题 一个是视频无水印的链接。
下面来看看具体的源码操作方法
header("Content-Type: text/json;charset=utf-8");
$url=$_GET["url"];
$UserAgent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 3.5.21022; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_ENCODING, '');
curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($curl);
curl_close($curl); //获取 preg_match('/
(?
preg_match('/playAddr: "(?
echo '请输入正确网址,格式为:https://xxx.com/douyin.php?url=视频地址';
}else{
$array = ['name' => $name['desc'],'url' => $url['url'],];
$json = json_encode($array,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT);
echo $json;
}
效果截图如下,url就是原视频链接,不带水印。
这里还有另外一个版本
header("Content-type: text/html; charset=utf-8");
$url_g=@$_GET['url'];//抖音视频地址 $api="https://api-hl.amemv.com/aweme/v1/aweme/detail/?retry_type=no_retry&iid=43619087057&device_id=57318346369&ac=wifi&channel=update&aid=1128&app_name=aweme&version_code=251&version_name=2.5.1&device_platform=android&ssmix=a&device_type=MI+8&device_brand=xiaomi&language=zh&os_api=22&os_version=5.1.1&uuid=865166029463703&openudid=ec6d541a2f7350cd&manifest_version_code=251&resolution=1080*1920&dpi=480&update_version_code=2512&_rticket=1559206461097&ts=1559206460&as=a115996edcf39c7adf4355&cp=9038c058c7f6e4ace1IcQg&mas=01af833c02eb8913ecc7909389749e6d89acaccc2c662686ecc69c&aweme_id=";//6691388713936653576 $cookie="##";//header请求头和cookie,请自己获取(涉及个人隐私,故不放出来),我可以帮你抓取.你也可以直接使用我的接口 [url=https://api.isoyu.com/ckplayer/douyin.jsp?url=]https://api.isoyu.com/ckplayer/douyin.jsp?url=[/url] $user_agent="Mozilla/5.0 (Linux; Android 8.0.0; MI 6 Build/OPR1.170623.027; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/62.0.3202.84 Mobile Safari/537.36"; function getLinkFromDouyinShareText($shareOrUrl){
$url="http".explode("http",$shareOrUrl)[1];
$url=explode("复制此链接,",$url)[0];
return $url;
} function getAwemeId($link,$UA){
$context=stream_context_create(array('http'=>array('header'=>'User-Agent:'.$UA)));
$html_text= file_get_contents($link,0,$context);
$str=explode("itemId: \"",$html_text)[1];
$str=explode("\",",$str)[0];
return $str;
} function doCurlGetRequest($url,$headers,$timeout = 5){
if($url == '' || $timeout <=0){
return false;
}
$con = curl_init((string)$url);
curl_setopt($con, CURLOPT_HEADER, false);
curl_setopt($con, CURLOPT_RETURNTRANSFER,true);
curl_setopt($con,CURLOPT_HTTPHEADER,$headers);
curl_setopt($con, CURLOPT_TIMEOUT,(int)$timeout);
return curl_exec($con);
} function getVideoData($api,$cookie,$awemeId){
$header=array("Accept-Encoding: utf-8",
"Cookie: ".$cookie,
"Host: api-hl.amemv.com",
"Connection: Keep-Alive",
"User-Agent: okhttp/3.10.0.1");
$data=json_decode(doCurlGetRequest($api.$awemeId,$header),true);
'status'=>true,
'nickname'=>$user_name,
'awemeId'=>$awemeId,
'headImage'=>$user_headImg,
'image'=>$image,
'videoUrl'=>$urls,
'music_urls'=>$music_urls,
'info'=>$info,
'time'=>time()
];
return json_encode($douyin);
} if(strstr($url_g,'http://v.douyin.com/')) {
$url_g = getLinkFromDouyinShareText($url_g);
$awemeId=getAwemeId($url_g,$user_agent);
echo getVideoData($api,$cookie,$awemeId);
}else{
echo json_encode(["status"=>false,"message"=>"地址无效"]);
}
实例地址:https://api.isoyu.com/ckplayer/douyin.php?url=
例子:https://api.isoyu.com/ckplayer/douyin.php?url=http://v.douyin.com/rYs9HU
返回:
{ "status":true, "nickname":"陳奕迅所長", "awemeId":"6629588912228535555", "headImage":"https://p9-dy.byteimg.com/aweme/720x720/c7a50016c177b8d83b6e.jpeg", "image":"http://p1-dy.byteimg.com/large/129e100017985e14f90e6.jpeg", "videoUrl":[ "http://v6-dy.ixigua.com/1bfeb00063e024eb6b0a1c5c1ccf461f/5cf72e65/video/m/220f880b47b03d54a789c8caed4897ab5f711610bbb50000474b6680d20e/?rc=anRmbjxrNGxqajMzO2kzM0ApQHRAb0ZHNDUzMzczNDQ1PDg5PDNAKXUpQGczdSlAZjN2KUBmaHV5cTFmc2hoZGY7NEBgY2hnbl5sYy1fLS1fLS9zcy1vI28jMTMwLjEuLy0tLjItLS0uL2k6Yi5wIzphLXEjOmAtbyNwYmZyaF4ranQ6Iy8uXg==", "http://v9-dy.ixigua.com/8a340ec9e22bbe529f779171175d0852/5cf72e65/video/m/220f880b47b03d54a789c8caed4897ab5f711610bbb50000474b6680d20e/", "https://aweme-hl.snssdk.com/aweme/v1/play/?video_id=v0200fb80000bg0gfio1ahq9jkkcfqcg&line=0&ratio=540p&media_type=4&vr_type=0&improve_bitrate=0", "https://api-hl.amemv.com/aweme/v1/play/?video_id=v0200fb80000bg0gfio1ahq9jkkcfqcg&line=1&ratio=540p&media_type=4&vr_type=0&improve_bitrate=0" ], "music_urls":[ "http://p3-dy.byteimg.com/obj/a02a0001f6153c8784e3" ], "info":{ "share_weibo_desc":"#在抖音,记录美好生活##明日之后明日之后 游戏人生,钢琴", "share_desc":"在抖音,记录美好生活", "share_title":"#明日之后明日之后 游戏人生,钢琴", "bool_persist":0, "share_title_myself":"", "share_title_other":"", "share_link_desc":"#在抖音,记录美好生活##明日之后明日之后 游戏人生,钢琴 %s 复制此链接,打开【抖音短视频】,直接观看视频!", "share_url":"https://iesdouyin.com/share/video/6629588912228535555/?region=CN&mid=6582505245845392141&u_code=gj49fkd1&titleType=title", "share_quote":"", "share_signature_desc":"TikTok: Make Every Second Count", "share_signature_url":"https://tiktokv.com/" }, "time":1559699531 }
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~