deejannon
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2017
05:22 PM
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?
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")
url.SetUrl("http://mysite.com/"+video.username)
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
2 REPLIES 2
renojim
Community Streaming Expert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2017
12:04 AM
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.
-JT
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.
-JT
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.
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.
norcaljohnny
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2017
07:02 PM
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 & or wrap your link in double quotes.
Also why are you not escaping your forward slashes as such>.... http:\/\/
Also why are you not escaping your forward slashes as such>.... http:\/\/