PHP获取某音去水印视频
本帖最后由 爱孤行 于 2020-9-15 11:55 编辑成品地址:http://wm.lololooo.xyz
本地下载程序(需PHP环境)
public function getLink(Request $request){
$url = I('url');
$pattern = '{(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?}';
preg_match($pattern,$url,$url);
if ($url){
$update['share_url'] = (string)$url;
}else{
$this->returnJson(0,'error',['code'=>0,'msg'=>'获取失败']);
}
$res = Db::name('log')->where('share_url',$update['share_url'])->find();
$reqData['code'] = 1;
$reqData['msg'] = '解析成功';
if (!$res){
$url = (string)$url;
$pattern = '{(?<=\.).*(?=\.com)}';
preg_match($pattern,$url,$type);
$type = (string)$type;
switch ($type){
case 'douyin':
$res = $this->douyin($url,'insert');
break;
case 'kuaishou':
$res = $this->ks($url,'insert');
break;
default:
$this->returnJson(0,'error',['code'=>0,'msg'=>'暂不支持该网站']);
break;
}
$reqData['addr'] = $res['addr_url'];
$reqData['title'] = $res['title'];
$reqData['cover'] = $res['cover'];
$reqData['is_url'] = $res['is_url'];
$this->returnJson(1,'success',$reqData);
}else{
//查询是否超过一小时,超过则更新
$over_time = time() - $res['create_time'];
if ($over_time>3600){
$url = (string)$url;
$pattern = '{(?<=\.).*(?=\.com)}';
preg_match($pattern,$url,$type);
$type = (string)$type;
if ($type=='douyin'){
$res = $this->douyin($url,'update');
}elseif ($type=='kuaishou'){
$res = $this->ks($url,'update');
}
$reqData['addr'] = $res['addr_url'];
$reqData['title'] = $res['title'];
$reqData['cover'] = $res['cover'];
$reqData['is_url'] = $res['is_url'];
$this->returnJson(1,'success',$reqData);
}else{
$reqData['addr'] = $res['addr_url'];
$reqData['cover'] = $res['cover'];
$reqData['title'] = $res['title'];
$reqData['is_url'] = $res['is_url'];
$this->returnJson(1,'success',$reqData);
}
}
}
protected function douyin($url,$action = 'insert'){
$update['share_url'] = $url;
$url = get_headers($url,true);
$url = $url['location'];
$pattern = '{(?<=share\/video\/).*(?=\/)}';
preg_match($pattern,$url,$video_id);
$video_id = $video_id;
$ql = QueryList::get('https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids='.$video_id);
$res = json_decode($ql->getHtml(),true);
$url = $res['item_list']['video']['play_addr']['url_list'];
$update['title'] = $res['item_list']['share_info']['share_title'];
$update['cover'] = $res['item_list']['music']['cover_large']['url_list'];
$update['create_time'] = time();
$url = str_replace('playwm','play',$url);
$update['is_url'] = $url;
$url = get_headers($url,true);
$url = $url['location'];
$update['addr_url'] = $url;
if ($action=='insert'){
$id = Db::name('log')->insertGetId($update);
$res = Db::name('log')->where('id',$id)->find();
}else{
$res = Db::name('log')->where('share_url',$update['share_url'])->update($update);
$res = Db::name('log')->where('share_url',$update['share_url'])->find();
}
return $res;
} ??没看懂 不能批量下载吗 感谢分享, 感谢分享 感谢分享 不多写点注释吗 这个厉害啊,不过我手机都是用的抖音伴侣 虽然用不上,但楼主很厉害 感谢老哥分享。