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

基于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使用,使用时请配合无水印解析模板使用即可!

1.使用本站下载的源码仅限于个人学习和非商业用途。
2.禁止将本站下载的源码用于搭建或支持任何违法、淫秽、暴力或侵犯他人合法权益的网站或应用。
3.使用本站下载的源码需遵守国家法律法规及相关规定,不得从事任何违法活动。
4.如若本站内容侵犯了原著者的合法权益,请联系我们进行处理。