Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help with getting video links

Hello All, I'm brand new to developing for Roku, and I've been messing around with some examples trying to get the hang of everything. I've managed to get an app working that parses a json file from a site, and populates a row with thumbnails and info for live streaming content. My problem is the site does not include direct links to play the live video, instead it has links to user pages that contain the live video, and a chatroom. Unless I'm mistaken, I should be able to use GetToString() to fetch the source code from the page and then Match the correct link using regex correct?

So this is what I have, and it doesn't seem to work. I've successfully tested my regex outside of the roku app and it worked, but it does not work in this example. It's supposed to match a link starting with http and ending in m3u8 Any ideas that could point me in the correct direction?

Function PlayVideo(video as object, json as boolean) as integer
    videoScreen = CreateObject("roVideoScreen")
    port = CreateObject("roMessagePort")
    videoScreen.SetMessagePort( port )
    url = createObject("roURLTransfer")
                            print url.GetUrl()
                            pre = url.GetToString()
                            test = CreateObject("roRegex","\bhttps://[.0-9A-Za-z-]+\.[A-Za-z]{2,63}+(?:/[]!#$%&'()*+,.0-9:;<=>?@A-Z[\\_`a-z{|}~^-]+){2}/[.0-9A-Z_a-z-]+\.m3u8","")
                            streamurl = test.Match(pre)
                            print streamurl
0 Kudos
Community Streaming Expert

Re: Help with getting video links

Wow!  I thought I knew regular expressions, but that makes me dizzy just looking at it.  Maybe start with a simpler expression, like "http://.*\.m3u8", and build it up to see where the match fails.

Also, you know that test.Match(pre) will return an array, right?  The print statement should print out the entire array.  The part of the string that matches would be streamurl[0] and any matched subexpressions, if used, would be streamurl[1], streamurl[2], ... etc.

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
Roku Guru

Re: Help with getting video links

Is it possible that the stream you are referring to is not loading because of the Same Origin Policy or CORS? If not make sure you have no ampersand in the url if so, convert it to &amp; or wrap your link in double quotes.

Also why are you not escaping your forward slashes as such>.... http:\/\/
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.