matrixebiz
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2017
04:09 PM
Check for 404 error
Hello, is there a simple Brightscript 2-3 lines of code that I can use to check if a url is alive or not and if it gives a 404 error then return the 404 error so I can try another url? Thank you
11 REPLIES 11
matrixebiz
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2017
03:23 PM
Re: Check for 404 error
Is this a hard question? All I need to do is check and see if the url is good (valid) or bad (404) in my RSG VideoScene.brs file.
Can I use some of this Function?
Can I use some of this Function?
Function check(thisurl) as string
request = CreateObject("roUrlTransfer")
port = CreateObject("roMessagePort")
request.SetMessagePort(port)
request.SetUrl(thisurl)
if (request.AsyncGetToString())
while (true)
msg = wait(0, port)
if (type(msg) = "roUrlEvent")
code = msg.GetResponseCode()
if (code = 200)
print"good"
return "good"
elseif (code =400 or code=404)
print("image not found")
return "bad"
else
print"error"; code
return "generic bad code"
endif
else if (event = invalid)
request.AsyncCancel()
endif
end while
endif
return invalid
End Function
matrixebiz
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2017
05:40 AM
Re: Check for 404 error
Anyone have the correct simplified code for me?
matrixebiz
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2017
07:52 AM
Re: Check for 404 error
Anyone?

squirreltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2017
08:29 AM
Re: Check for 404 error
not tested
Function Ping()
UT = CreateObject( "roUrlTransfer" )
port = CreateObject("roMessagePort")
UT.SetPort(port)
UT.SetUrl("URL HERE")
UT.AsyncHead()
event = wait (0, port)
if type(event) = "roUrlEvent"
if event.GetResponseCode() = 200
'do something'
else if event.GetResponseCode() = 404
'do something else'
end if
end if
End Function
Kinetics Screensavers
matrixebiz
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2017
02:33 PM
Re: Check for 404 error
Hello, thanks for responding but I get this error;
BRIGHTSCRIPT: ERROR: roUrlTransfer: creating MAIN|TASK-only component failed on RENDER
'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec) in pkg:/components/VideoScene.brs(36)
036: UT.SetPort(port)
This is a RSG channel - https://github.com/rokudev/videoplayer-channel
BRIGHTSCRIPT: ERROR: roUrlTransfer: creating MAIN|TASK-only component failed on RENDER
'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec) in pkg:/components/VideoScene.brs(36)
036: UT.SetPort(port)
This is a RSG channel - https://github.com/rokudev/videoplayer-channel

squirreltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2017
02:37 PM
Re: Check for 404 error
The function works, putting it in the right place is up to you. I don't know RSG but it looks like it's in the wrong thread.
Kinetics Screensavers
matrixebiz
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2017
12:46 PM
Re: Check for 404 error
Anyone know the Scene Graph coding? and where in the VideoScene.brs file I can put a URL 404 check function?
https://github.com/rokudev/videoplayer-channel
https://github.com/rokudev/videoplayer-channel
rymawby
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2017
01:42 PM
Re: Check for 404 error
Have you tried putting it in the UriHandler Task?
matrixebiz
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2017
09:45 AM
Re: Check for 404 error
I think I did try that file (UriHandler.brs) but the actual url gets converted into a uri before it hits this file so that file confused me on where to put the url check.