抖音、快手无水印解析算法,下载本源码,按下面使用方法调用,仅供学习交流,严禁用于商业用途!

基于PHP开发的抖音短视频、快手解析,完整算法API插图
抖音、快手无水印解析
警告:本解析不再维护,请查看新版短视频去水印解析,新版解析支持全网各大平台

请求实例(你的网址/?url="抖音或快手链接"):

http://127.0.0.1/?url=https://v.douyin.com/ehHpu7V/

返回数据:

{
	"code": 200,
	"message": {
		"nickname": "车探视界",
		"video_url": "https://aweme.snssdk.com/aweme/v1/play/?video_id=v0200fg10000c1qli8t76cruj05otmgg&ratio=720p&line=0",
		"music": "https://sf6-cdn-tos.douyinstatic.com/obj/ies-music/6909127277620431623.mp3"
	}
}
  • "code":200,表示成功解析
  • "nickname":"作者名称界",
  • "video_url":"视频地址",
  • "music":"背景音乐"
算法及使用方法:

1.新建“index.php”文件,复制下面代码


<?php
require 'CWaterMask.php';

echo getUrl();

    function getUrl()
    {
        $data = \CWaterMask::analyzing($_GET['url']);
		return  $data;
    }

2.在同目录新建“analysis.php”文件,复制算法代码

算法已经更新,可正常使用,如有失效,联系客户处理或退款!
隐藏内容
<?php
class CWaterMask {
	
    static public function analyzing($url) {
		
        preg_match('/([\w-]+\.)+\w+(\:\d{2,6})?/', $url, $domain);
        switch ($domain[0]) {
            case '':
                return self::result(500, '请传入解析url参数,例:https://www.360mb.net/?url=https://v.douyin.com/ehHpu7V/');
            break;
            case 'v.douyin.com':
                return self::douyin($url);
            break;
            case 'v.kuaishou.com':
                return self::kuaishou($url);
            break;
            default:
                return self::result(500, '抱歉,此url暂不支持!');
        }
    }
	
    static public function douyin($url) {
		
        $url = self::httpRequest($url, 'GET');
        preg_match('/(?<=video\/)\d*(?=\/\?region)/', $url['location'], $matches);
        $item_ids = $matches[0];
        $vidoUrl = 'https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=' . $item_ids;
        $result = self::httpRequest($vidoUrl, 'GET');
        $vid = $result['response']['item_list'][0]['video']['play_addr']['uri'];
        if (isset($vid)) {
            $video_url = 'https://aweme.snssdk.com/aweme/v1/play/?video_id=' . $vid . '&ratio=720p&line=0';
            $music = $result['response']['item_list'][0]['music']['play_url']['uri'];
            $nickname = $result['response']['item_list'][0]['author']['nickname'];
            $return = array('nickname' => $nickname, 'video_url' => $video_url, 'music' => $music);
            return self::result(200, $return);
        } else {
            return self::result(500, '解析出错!');
        }
    }
	
    static public function kuaishou($url) {
		
        $vurl = self::httpRequest($url, 'GET');
        preg_match('/(?<=video\/)\w*(?=\?fid)/', $vurl['location'], $matches);
        $str_qury1 = 'query visionVideoDetail($photoId: String, $type: String, $page: String, $webPageArea: String)';
        $str_qury2 = '(photoId: $photoId, type: $type, page: $page, webPageArea: $webPageArea)';
        $query = array("operationName" => "visionVideoDetail", "variables" => array('photoId' => $matches[0], "page" => "detail"), "query" => $str_qury1 . "{\n visionVideoDetail" . $str_qury2 . "{\n photo {\n id\n duration\n caption\n likeCount\n realLikeCount\n coverUrl\n photoUrl\n }\n}\n}\n",);
        $query = json_encode($query, 320);
        $headers = array('content-type: application/json', 'Referer:' . $vurl['location']);
        $result = self::httpRequest('https://video.kuaishou.com/graphql', 'POST', $query, $headers);
        if (isset($result['response']['data']['visionVideoDetail']['photo']['photoUrl'])) {
            return self::result(200, $result['response']['data']['visionVideoDetail']['photo']);
        } else {
            return self::result(500, '解析出错!');
        }
    }
	
    static public function httpRequest($url, $method = 'POST', $postfields = null, $headers = array()) {
		
        $method = strtoupper($method);
        $ci = curl_init();
        curl_setopt($ci, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
        curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 60);
        curl_setopt($ci, CURLOPT_TIMEOUT, 30);
        curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1);
        switch ($method) {
            case "POST":
                curl_setopt($ci, CURLOPT_POST, true);
                if (!empty($postfields)) {
                    $tmpdatastr = is_array($postfields) ? http_build_query($postfields) : $postfields;
                    curl_setopt($ci, CURLOPT_POSTFIELDS, $tmpdatastr);
                }
            break;
            default:
                curl_setopt($ci, CURLOPT_CUSTOMREQUEST, $method);
            break;
        }
        $ssl = preg_match('/^https:\/\//i', $url) ? TRUE : FALSE;
        curl_setopt($ci, CURLOPT_URL, $url);
        if ($ssl) {
            curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($ci, CURLOPT_SSL_VERIFYHOST, FALSE);
        }
        curl_setopt($ci, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ci, CURLOPT_MAXREDIRS, 2);
        curl_setopt($ci, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ci, CURLINFO_HEADER_OUT, true);
        $response = json_decode(curl_exec($ci), true);
        $requestinfo = curl_getinfo($ci);
        $http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
        $location = curl_getinfo($ci, CURLINFO_EFFECTIVE_URL);
        curl_close($ci);
        return array('location' => $location, 'response' => $response, 'requestinfo' => $requestinfo);
    }
	
    static public function result($errno = 0, $data = '') {
		
        header("Content-type: application/json;charset=utf-8");
        $errno = intval($errno);
        $result = array('code' => $errno, 'message' => $data);
        return json_encode($result, 320);
    }
}

3.将新建的两个文件:“index.php”、“analysis.php”上传至服务器

4.最上面的访问实例即可解析到无水印的视频链接了,如:(http://你的网址/?url=https://v.douyin.com/ehHpu7V/)

注:本解析算法属于json解析模式,适用于api使用,使用时请配合无水印解析模板使用即可!

发表评论

后才能评论

本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。

本站部分资源需要解压密码,如需解压密码,解压密码则为“www.360mb.net”。

对于会员专享、整站源码、程序插件、网站模板、网页模版等类型的素材,文章内用于介绍的图片通常并不包含在对应可供下载素材包内。这些相关商业图片需另外购买,且本站不负责(也没有办法)找到出处。 同样地一些字体文件也是这种情况,但部分素材会在素材包内有一份字体下载链接清单。

如果您已经成功付款但是网站没有弹出成功提示,请联系站长提供付款信息为您处理

源码素材属于虚拟商品,具有可复制性,可传播性,一旦授予,不接受任何形式的退款、换货要求。请您在购买获取之前确认好 是您所需要的资源