批处理获取虎牙直播视频流 代码更简洁 利用jq解析json

包含 Base64Decode.exe jq.exe 链接: https://pan.baidu.com/s/13pVJU8X6Nx72deVnrZfDwg 提取码: pe4p

@echo off

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: IMPORTANT User-Agent Must be set to -user_agent "HYSDK(Windows, 20000308)" ::
::::::::::::::::::::::::::::::::::::::::::::::::::::^^^^^^^^^^^^^^^^^^^^^^^^::::
chcp 65001 1>nul 2>nul

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/=%"

:loop
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') DO set "data=%%i"

echo [FlvUrls]
echo %data% |jq -M -r ".data[].gameStreamInfoList[]| .sFlvUrl +\"/\"+.sStreamName+\".\"+.sFlvUrlSuffix +\"?\"+.sFlvAntiCode"|sed "s/amp;//g"
echo [HlsUrls]
echo %data% |jq -M -r ".data[].gameStreamInfoList[]| .sHlsUrl +\"/\"+.sStreamName+\".\"+.sHlsUrlSuffix +\"?\"+.sFlvAntiCode"|sed "s/amp;//g"
::echo.
::echo %data% |jq -M -r ".data[].gameStreamInfoList[]| .sP2pUrl +\"/\"+.sStreamName+\".\"+.sP2pUrlSuffix +\"?\"+.sFlvAntiCode"|sed "s/amp;//g"

包含 Base64Decode.exe jq.exe 链接: https://pan.baidu.com/s/13pVJU8X6Nx72deVnrZfDwg 提取码: pe4p

posted @ 2020-08-12 02:15  1CM  阅读(752)  评论(0编辑  收藏  举报