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

	$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

你可能感兴趣的:(每天一个小知识,php)