包含 Base64Decode.exe 链接:https://pan.baidu.com/s/1zPdJwwi3dlSpF-S0sGvDrw 提取码:9dvf

@echo off
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: IMPORTANT User-Agent Must be set to -user_agent "HYSDK(Windows, 20000308)" ::
::::::::::::::::::::::::::::::::::::::::::::::::::::^^^^^^^^^^^^^^^^^^^^^^^^::::

set roomid=%~1
if "%roomid%"=="" (
echo Usage: %~n0 [HUYA Room ID] or [HUYA Room URL]
echo   Example %~n0 123456
echo   Example %~n0 https://www.huya.com/123456
exit /b
)

set "roomid=%roomid: =%"
set "roomid=%roomid:https://www.huya.com/=%"

set inurl=https://www.huya.com/%roomid%

FOR /F "delims=" %%i IN (\'curl -sk %inurl%^|grep -Eo """stream""(.*)" ^| grep -Eo """(.*)""" ^| sed "s/stream//g;s/://g;s/""//g;s/ //g"^|base64decode^|sed "s/""//g"\') DO set "data=%%i"
::echo "%data%"|sed "s/,/\n/g">GetHuyaStreamURL.txt

::sStreamName
FOR /F "delims=" %%i IN (\'echo "%data%"^|sed "s/,/\n/g"^|grep -Eo -m 1 "sStreamName(.*)" ^| sed "s/sStreamName//g;s/""//g;s/://g"\') Do set sStreamName=%%i
:: echo %sStreamName%

::sFlvAntiCode
FOR /F "delims=" %%i IN (\'echo "%data%"^|sed "s/,/\n/g"^|grep -Eo -m 1 "sFlvAntiCode(.*)" ^| sed "s/sFlvAntiCode//g;s/""//g;s/://g"\') Do set "sFlvAntiCode=%%i"
set "sFlvAntiCode=%sFlvAntiCode:&=&%"
:: echo "%sFlvAntiCode%"

::iBitRate
FOR /F "delims=" %%i IN (\'echo "%data%"^|sed "s/,/\n/g"^|grep -Eo -m 1 "iBitRate(.*)" ^| sed "s/iBitRate//g;s/""//g;s/://g;s/}//g;s/,//g;s/]//g"\') Do set iBitRate=%%i
:: echo %iBitRate%

::bitRate
FOR /F "delims=" %%i IN (\'echo "%data%"^|sed "s/,/\n/g"^|grep -Eo -m 1 "bitRate(.*)" ^| sed "s/bitRate//g;s/""//g;s/://g;s/}//g;s/,//g;s/]//g"\') Do set bitRate=%%i
:: echo bitRate %bitRate%

::iWebDefaultBitRate
FOR /F "delims=" %%i IN (\'echo "%data%"^|sed "s/,/\n/g"^|grep -Eo -m 1 "iWebDefaultBitRate(.*)" ^| sed "s/iWebDefaultBitRate//g;s/""//g;s/://g;s/}//g;s/,//g;s/]//g"\') Do set iWebDefaultBitRate=%%i
:: echo WebDefaultBitRate %iWebDefaultBitRate%

echo BitRate %iBitRate% %bitRate% %iWebDefaultBitRate%
:: if "%iBitRate%"=="0" set iBitRate=%bitRate%
:: if "%bitRate%"=="%iWebDefaultBitRate%" set iBitRate=%iWebDefaultBitRate%

:: &ratio=%iBitRate%
echo [FlvUrl]
FOR /F "delims=" %%i IN (\'echo "%data%"^|sed "s/,/\n/g"^|grep -Eo "sFlvUrl.http(.*)"^|grep -Eo -m 1 "http(.*)"^|sed "s/sFlvUrl//g;s/""//g;s/\\\\//g"\') Do (
  echo "%%i/%sStreamName%.flv?%sFlvAntiCode%"
  set FlvUrl="%%i/%sStreamName%.flv?%sFlvAntiCode%"
  echo.
)

goto next
echo [HlsUrl]
FOR /F "delims=" %%i IN (\'echo "%data%"^|sed "s/,/\n/g"^|grep -Eo "sHlsUrl.http(.*)"^|grep -Eo "http(.*)"^|sed "s/sHlsUrl//g;s/""//g;s/\\\\//g"\') Do (
  echo "%%i/%sStreamName%.m3u8?%sFlvAntiCode%"
  echo.
)
:next

if not DEFINED FlvUrl got end
ffplay -hide_banner -user_agent "HYSDK(Windows, 20000308)" -i %FlvUrl%

:end
::pause

包含 Base64Decode.exe 链接:https://pan.baidu.com/s/1zPdJwwi3dlSpF-S0sGvDrw 提取码:9dvf

版权声明:本文为nlsoft原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/nlsoft/p/13475836.html