欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

抖音短视频去水印解析 - thinkphp

程序员文章站 2022-03-04 18:53:40
...
	$url = input('get.url');
    $down = input('get.down');
    if (empty($url)) {
      return json([
        'code' => 200,
        'msg' => '链接不能为空',
        'data' => '',
      ]);
    }
    if (empty($down)) {
      $down = 2;
    }
    // 获取跳转html
    $res = http_get($url);
    preg_match('/href="(.*?)">Found/', $res, $matches);
    // 获取视频id
    preg_match('/video\/(.*?)\//', $matches[0], $itemId);
    // 获取视频API数据
    $apiDAta = json_decode(file_get_contents('https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=' . $itemId[1]), true)['item_list'][0];
    // 二次解析视频
    preg_match('/href="(.*?)">Found/', http_get(str_replace("playwm", "play", $apiDAta['video']['play_addr']['url_list'][0])), $videoObj);
    $apiDAta['video']['play_addr']['url_list'][0] = $videoObj[1];
    if ($down == 1) {
      header('Location: ' . $videoObj[1]);
      exit;
    } else {
      return json([
        'code' => 200,
        'msg' => '成功',
        'data' => $apiDAta,
      ]);
    }

抖音短视频解析 - thinkphp

视频data地址:data.video.play_addr.url_list[0]

演示地址:https://api.haodanxia.com/tools/tools/get_dy_video_data?url=https://v.douyin.com/JYthvL6

好单侠官方 - www.haodanxia.com