Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

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 !

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

I think we need more info …

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

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 --> vbscript

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

URLArray = Array("https://5ac31d8a4c9af.streamlock.net/saheltv/_definst_/myStream/chunklist_w956788169.m3u8"_

For Each URL in URLArray
	wscript.echo URL & vbCrlf & CheckOnline(URL) & vbCrlf & String(100,"-")
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
	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
		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
		CreateObject( "WScript.Shell" ).Run _
		cmd & "cscript //nologo """ & _
		WScript.ScriptFullName & _
		""" " & Str
	End If
End Sub

I got as response results :


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
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
400 Bad Request
Connection: keep-alive
Date: Mon, 30 Dec 2019 23:56:04 GMT
Content-Type: text/html; charset=iso-8859-1
Location: https://www.chocradios.ch/djbuzzradio_windows.mp3.asx
Server: nginx
X-Powered-By: PleskLin

STATUS : 302    Found
302 Found

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close