Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check if a video stream is online or not in Vbscript?

Status
Not open for further replies.

hackoo

Programmer
Jan 31, 2003
28
0
0
TN
Hi everyone !
I wonder what is the parameter or the value to look for to check if a video stream is online or not in vbscript ?
Thank you !
 
I took a look at this HTTP Status Codes
So this what i have tried as code until now, but, it give me a wrong results, because i have checked all those streams with VLC and they works 5/5, but with this script the second and the third stream give me as offline ??

Code:
Option Explicit
Dim Title,URLArray,URL,ws,Msg,Data
Title = "Audio and Video Stream Checker"
Call ForceCScriptExecution(Title)

URLArray = Array("[URL unfurl="true"]https://5ac31d8a4c9af.streamlock.net/saheltv/_definst_/myStream/chunklist_w956788169.m3u8"_[/URL]
,"[URL unfurl="true"]http://aska.ru-hoster.com:8053/autodj"_[/URL]
,"[URL unfurl="true"]http://www.chocradios.ch/djbuzzradio_windows.mp3.asx")[/URL]


For Each URL in URLArray
	wscript.echo URL & vbCrlf & 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
		wscript.echo "STATUS : "& CInt(h.status) & vbTab & h.statusText
		Select Case CInt(h.status) 
		Case 200,201,202,204
			CheckOnline = "ONLINE"
		Case 404,401,412,415,500,501,500,501
			CheckOnline = "OFFLINE" & vbCrlf & h.status & " " & h.statusText
		Case Else 
			CheckOnline = "OFFLINE" & vbCrlf & h.status & " " & h.statusText
		End Select
	Else
		CheckOnline = "OFFLINE" & vbCrlf &_
		"Error Description: " & Err.Description
		On Error Goto 0
	End IF
End Function
'----------------------------------------------------
Sub ForceCScriptExecution(Title)
	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
'--------------------------------------------------

I got as response results :

Code:
Cache-Control: no-cache
Date: Mon, 30 Dec 2019 23:56:03 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


STATUS : 200    OK
[URL unfurl="true"]https://5ac31d8a4c9af.streamlock.net/saheltv/_definst_/myStream/chunklist_w956788169.m3u8[/URL]
ONLINE
----------------------------------------------------------------------------------------------------
Cache-Control: no-cache
Date: Mon, 30 Dec 2019 23:56:06 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


STATUS : 400    Bad Request
[URL unfurl="true"]http://aska.ru-hoster.com:8053/autodj[/URL]
OFFLINE
400 Bad Request
----------------------------------------------------------------------------------------------------
Connection: keep-alive
Date: Mon, 30 Dec 2019 23:56:04 GMT
Content-Type: text/html; charset=iso-8859-1
Location: [URL unfurl="true"]https://www.chocradios.ch/djbuzzradio_windows.mp3.asx[/URL]
Server: nginx
X-Powered-By: PleskLin


STATUS : 302    Found
[URL unfurl="true"]http://www.chocradios.ch/djbuzzradio_windows.mp3.asx[/URL]
OFFLINE
302 Found
----------------------------------------------------------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top