我想知道用于检查vbscript中的视频或音频流是否在线的参数或值是什么?
所以到目前为止,我一直尝试将此作为代码,但是,这给了我错误的结果,因为我已经使用VLC检查了所有这些流,并且它们的工作效率为5/5,但是使用此脚本,第二个和第三个流给出了我处于离线状态
Option Explicit
Dim Title,URLArray,URL,ws,Msg,Data
Title = "Audio and Video Stream Checker"
URLArray = Array("https://5ac31d8a4c9af.streamlock.net/saheltv/_definst_/myStream/chunklist_w956788169.m3u8"_
,"http://aska.ru-hoster.com:8053/autodj"_
,"http://www.chocradios.ch/djbuzzradio_windows.mp3.asx")
Call ForceCScriptExecution()
For Each URL in URLArray
wscript.echo "The stream " & URL & " is "& CheckOnline(URL) & vbCrlf & String(100,"-")
Next
'----------------------------------------------------
Function CheckOnline(URL)
On Error Resume Next
Const WHR_EnableRedirects = 6
Dim h,AllResponseHeaders
Set h = CreateObject("WinHttp.WinHttpRequest.5.1")
h.Option(WHR_EnableRedirects) = False 'disable redirects
h.Open "HEAD", URL , False
h.Send()
AllResponseHeaders = h.GetAllResponseHeaders()
wscript.echo AllResponseHeaders
If Err.number = 0 Then
If h.status = 200 OR h.status = 201 OR h.status = 202 OR h.status = 203 OR h.status = 204 Then
CheckOnline = "ONLINE"
Else
CheckOnline = "OFFLINE"
End IF
Else
CheckOnline = "OFFLINE" & vbCrlf & Err.Description
On Error Goto 0
End IF
End Function
'----------------------------------------------------
Sub ForceCScriptExecution()
Dim Arg, Str, cmd
cmd = "CMD /K Title " & Title &" & color 0A & "
If Not LCase( Right( WScript.FullName, 12 ) ) = "\cscript.exe" Then
For Each Arg In WScript.Arguments
If InStr( Arg, " " ) Then Arg = """" & Arg & """"
Str = Str & " " & Arg
Next
CreateObject( "WScript.Shell" ).Run _
cmd & "cscript //nologo """ & _
WScript.ScriptFullName & _
""" " & Str
WScript.Quit
End If
End Sub
'--------------------------------------------------
我得到这样的回应:
Cache-Control: no-cache
Date: Sat, 28 Dec 2019 00:14:27 GMT
Content-Length: 232
Content-Type: application/vnd.apple.mpegurl
Accept-Ranges: bytes
Server: WowzaStreamingEngine/4.7.8
Access-Control-Expose-Headers: Date, Server, Content-Type, Content-Length
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: OPTIONS, GET, POST, HEAD
Access-Control-Allow-Headers: Content-Type, User-Agent, If-Modified-Since, Cache-Control, Range
The stream https://5ac31d8a4c9af.streamlock.net/saheltv/_definst_/myStream/chunklist_w956788169.m3u8 is ONLINE
-------------------------------------------------------------------------------
Cache-Control: no-cache
Date: Sat, 28 Dec 2019 00:14:28 GMT
Pragma: no-cache
Content-Type: text/html; charset=utf-8
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Server: Icecast 2.4.2
The stream http://aska.ru-hoster.com:8053/autodj is OFFLINE
-------------------------------------------------------------------------------
Connection: keep-alive
Date: Sat, 28 Dec 2019 00:14:28 GMT
Content-Type: text/html; charset=iso-8859-1
Location: https://www.chocradios.ch/djbuzzradio_windows.mp3.asx
Server: nginx
X-Powered-By: PleskLin
The stream http://www.chocradios.ch/djbuzzradio_windows.mp3.asx is OFFLINE
-------------------------------------------------------------------------------
答案 0 :(得分:1)
这里可以使用WMP实施:
requests