yf1197565391 发表于 2024-11-22 16:54:41

yy轮播php

本帖最后由 yf1197565391 于 2024-11-22 16:59 编辑

论坛里找的老帖子,肥羊大佬的打开时全是视频,请大佬修改一下成正常php

<?php
date_default_timezone_set("Asia/Shanghai");
$firstrid = empty($_GET['id']) ? "17829" : trim($_GET['id']);
$quality = "4";

$checkUrl = "https://wap.yy.com/mobileweb/$firstrid";
$header = array(
    'Referer: https://wap.yy.com',
    'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 16_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Mobile/15E148 Safari/604.1'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $checkUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
$data = curl_exec($ch);
curl_close($ch);

function aes_decrypt($ciphertext, $key, $iv)
{
    return openssl_decrypt($ciphertext, 'AES-256-CBC', $key, 0, $iv);
}

$key = "abcdefghijklmnopqrstuvwxyz123456";
$iv = "1234567890123456";
$mediaurl = aes_decrypt("vcnTSiZsSUWtlZRxx+FuRnM7F1b1FlSVueFKcxewvKVbe9bXE49HXuq1dHha2K7cSic4yOuClWpau1RibQeO2g==", $key, $iv);

$realdata = "";
$rid = "";
$reg = "/md5Hash[\s\S]*?sid.*'(.*)'.*?getQuery/i";
preg_match($reg, $data, $realdata);
if (count($realdata) > 0) {
    $rid = $realdata;
} else {
    header('location:' . $mediaurl);
    exit();
}

$millis_13 = round(microtime(true) * 1000);
$millis_10 = time();
$data = '{"head":{"seq":' . $millis_13 . ',"appidstr":"0","bidstr":"121","cidstr":"' . $rid . '","sidstr":"' . $rid . '","uid64":0,"client_type":108,"client_ver":"5.11.0-alpha.4","stream_sys_ver":1,"app":"yylive_web","playersdk_ver":"5.11.0-alpha.4","thundersdk_ver":"0","streamsdk_ver":"5.11.0-alpha.4"},"client_attribute":{"client":"web","model":"","cpu":"","graphics_card":"","os":"chrome","osversion":"106.0.0.0","vsdk_version":"","app_identify":"","app_version":"","business":"","width":"1536","height":"864","scale":"","client_type":8,"h265":0},"avp_parameter":{"version":1,"client_type":8,"service_type":0,"imsi":0,"send_time":' . $millis_10 . ',"line_seq":-1,"gear":' . $quality . ',"ssl":1,"stream_format":0}}';
$url = "https://stream-manager.yy.com/v3/channel/streams?uid=0&cid=$rid&sid=$rid&appid=0&sequence=$millis_13&encode=json";
$headers = array(
    'Content-Type: text/plain;charset=UTF-8',
    'Referer: https://www.yy.com/',
    'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.42'
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$result = curl_exec($ch);
$result = json_decode($result, true);
curl_close($ch);
if (array_key_exists('avp_info_res', $result)) {
    $a = $result['avp_info_res']['stream_line_addr'];
    $mediaurl = array_values($a)['cdn_info']['url'];
    header('location:' . $mediaurl);
    exit();
} else {
    header('location:' . $mediaurl);
    exit();
}huya   web网页端
<?php
date_default_timezone_set("Asia/Shanghai");
$type = empty($_GET['type']) ? "nodisplay" : trim($_GET['type']);
$id = empty($_GET['id']) ? "shangdi" : trim($_GET['id']);
$cdn = empty($_GET['cdn']) ? "hwcdn" : trim($_GET['cdn']);
$media = empty($_GET['media']) ? "flv" : trim($_GET['media']);
$roomurl = "https://m.huya.com/" . $id;

function get_content($apiurl, $flag)
{
    if ($flag == "mobile") {
      $headers = array(
            'Content-Type: application/x-www-form-urlencoded',
            'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 16_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Mobile/15E148 Safari/604.1'
      );
    } else {
      $arr = [
            "appId" => 5002,
            "byPass" => 3,
            "context" => "",
            "version" => "2.4",
            "data" => new stdClass(),
      ];
      $postData = json_encode($arr);
      $headers = array(
            'Content-Type: application/json',
            'Content-Length: ' . strlen($postData),
            'upgrade-insecure-requests: 1',
            'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36'
      );
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $apiurl);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    if ($flag == "uid") {
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
    }
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}

function aes_decrypt($ciphertext, $key, $iv)
{
    return openssl_decrypt($ciphertext, 'AES-256-CBC', $key, 0, $iv);
}

$key = "abcdefghijklmnopqrstuvwxyz123456";
$iv = "1234567890123456";
$mediaurl = aes_decrypt("fIuPMpBI1RpRnM2JhbYHzvwCvwhHBF7Q+8k14m9h3N5ZfubHcDCEk08TnLwHoMI/SG7bxpqT6Rh+gZunSpYHf1JM/RmEC/S1SjRYWw6rwc3gGo3Rrsl3sojPujI2aZsb", $key, $iv);

$uid = json_decode(get_content("https://udblgn.huya.com/web/anonymousLogin", "uid"), true)["data"]["uid"];

function get_uuid()
{
    $now = intval(microtime(true) * 1000);
    $rand = rand(0, 1000) | 0;
    return intval(($now % 10000000000 * 1000 + $rand) % 4294967295);
}

function process_anticode($anticode, $uid, $streamname)
{
    parse_str($anticode, $q);
    $q["t"] = '102';
    $q["ctype"] = 'tars_mp';
    $q["wsTime"] = dechex(time() + 21600);
    $q["ver"] = "1";
    $q["sv"] = date('YmdH');
    $q["seqid"] = strval(intval($uid) + intval(microtime(true) * 1000));
    $q["uid"] = strval($uid);
    $q["uuid"] = strval(get_uuid());
    $ss = md5("{$q["seqid"]}|{$q["ctype"]}|{$q["t"]}");
    $q["fm"] = base64_decode($q["fm"]);
    $q["fm"] = str_replace(["$0", "$1", "$2", "$3"], [$q["uid"], $streamname, $ss, $q["wsTime"]], $q["fm"]);
    $q["wsSecret"] = md5($q["fm"]);
    unset($q["fm"]);
    if (array_key_exists("txyp", $q)) {
      unset($q["txyp"]);
    }
    return http_build_query($q);
}

function format($livearr, $uid)
{
    $stream_info = ['flv' => [], 'hls' => []];
    $cdn_type = ['HY' => 'hycdn', 'AL' => 'alicdn', 'TX' => 'txcdn', 'HW' => 'hwcdn', 'HS' => 'hscdn', 'WS' => 'wscdn'];
    foreach ($livearr["roomInfo"]["tLiveInfo"]["tLiveStreamInfo"]["vStreamInfo"]["value"] as $s) {
      if ($s["sFlvUrl"]) {
            $stream_info["flv"][$cdn_type[$s["sCdnType"]]] = $s["sFlvUrl"] . '/' . $s["sStreamName"] . '.' . $s["sFlvUrlSuffix"] . '?' . process_anticode($s["sFlvAntiCode"], $uid, $s["sStreamName"]);
      }
      if ($s["sHlsUrl"]) {
            $stream_info["hls"][$cdn_type[$s["sCdnType"]]] = $s["sHlsUrl"] . '/' . $s["sStreamName"] . '.' . $s["sHlsUrlSuffix"] . '?' . process_anticode($s["sHlsAntiCode"], $uid, $s["sStreamName"]);
      }
    }
    return $stream_info;
}

$res = get_content($roomurl, "mobile");
$reg = "/\<script\> window.HNF_GLOBAL_INIT = (.*) \<\/script\>/i";
preg_match($reg, $res, $realres);
$realdata = json_decode($realres, true);

if (array_key_exists("exceptionType", $realdata)) {
    header('location:' . $mediaurl);
    exit();
} elseif ($realdata["roomInfo"]["eLiveStatus"] == 2) {
    $realurl = format($realdata, $uid);
    if ($type == "display") {
      print_r($realurl);
      exit();
    }
    if ($media == "flv") {
      switch ($cdn) {
            case $cdn:
                $mediaurl = str_replace("http://", "https://", $realurl["flv"][$cdn]);
                break;
            default:
                $mediaurl = str_replace("http://", "https://", $realurl["flv"]["hwcdn"]);
                break;
      }
    }
    if ($media == "hls") {
      switch ($cdn) {
            case $cdn:
                $mediaurl = str_replace("http://", "https://", $realurl["hls"][$cdn]);
                break;
            default:
                $mediaurl = str_replace("http://", "https://", $realurl["hls"]["hwcdn"]);
                break;
      }
    }
    header('location:' . $mediaurl);
    exit();
} elseif ($realdata["roomInfo"]["eLiveStatus"] == 3) {
    header('location:' . "https:" . base64_decode($realdata["roomProfile"]["liveLineUrl"]));
    exit();
} else {
    header('location:' . $mediaurl);
    exit();
}



Mr.YanG 发表于 2024-11-22 18:21:41

找GitHub 改下就能用....{:2_26:}

yf1197565391 发表于 2024-11-22 19:06:36

Mr.YanG 发表于 2024-11-22 18:21
找GitHub 改下就能用....

怎么改?请指教

lyliuhui 发表于 2024-11-22 19:19:03

寻求答案,在哪里

gbz2 发表于 2024-11-22 19:23:55

这代码能用吗

yf1197565391 发表于 2024-11-22 19:36:24

gbz2 发表于 2024-11-22 19:23
这代码能用吗

能用!!!

zow1990 发表于 2024-11-22 22:00:19

yf1197565391 发表于 2024-11-22 19:36
能用!!!

能用你还改什么?

Mr.YanG 发表于 2024-11-23 00:31:06

yf1197565391 发表于 2024-11-22 19:06
怎么改?请指教

打错字了...找chatgpt就可以了..
其实第一个代码本身就能用..

s4440 发表于 2024-11-23 02:13:13

大佬这个yy和虎牙的格式是不是http://ip:端口/yy.php?id=*****

dragoneast23 发表于 2024-11-23 08:44:57

本帖最后由 dragoneast23 于 2024-11-23 09:00 编辑

我这里测试两个都不能用哦,哪位给改好再发一下哦,谢谢

gbz2 发表于 2024-11-23 10:42:45

这个码应该不能用了吧,视频把它的视频删掉不就行了,还要那麻烦
页: [1]
查看完整版本: yy轮播php