I am trying to set up a button at my parents house to let them watch a webcam feed on a Chromecast. The URL for the feed has a token that changes so I can’t just copy and paste the address into a rule, but enough of it stays the same for me to find it with a regular expression. I was looking to extract the URL for a webcam from a webpage to pass along to the Chromecast binding when a button on HabPanel is pressed.
The address takes the form https://e1-na3.angelcam.com/m6-na3/2663/playlist.m3u8?token=eyJhbGlhcyI6ICIyNjYzIiwgInRpbWUiOiAxNTIzNTgzOTY5NzE3MjQ5LCAidGltZW91dCI6IDM2MDB9.6dfd9027064d2183872351ceec1b9261f9ef7281caca29fa35ead3a3f53a8bf3
The RegEx e1-na.*?(?=’) works fine on https://regex101.com/ when I paste in the HTML from the address. However RegEx doesn’t extract any data instead NULL gets written to the CanalCam_URL item.
As a test I wrote the contents of the urltemp variable to a string variable and it is dumping the HTML to it.
I also set logging to TRACE on RegEx (org.eclipse.smarthome.transform.regex) and it says
' by the function 'e1-na.*?(?=\')' 12-Apr-2018 20:41:34.525 [DEBUG] [ransform.regex.internal.RegExTransformationService] - the given regex '^e1-na.*?(?=\')$' doesn't match the given content ' (THE PAGE HTML HERE) ' -> couldn't compute transformation
So it looks like it is reading the RegEx .(e1-na.?)’ as ^e1-na.?(?=’)$. I’m not sure why it is not reading it correctly.
Here is the rule runs when the button in HabPanel is pressed.
rule "Canal Cam URL Update" when Item CanalCam_Play_Switch received command ON then var String url = "https://v.angelcam.com/iframe?v=vbolkpk8y8&autoplay=1" var String urltemp = sendHttpGetRequest(url) var canalcamurl = transform("REGEX", ".(e1-na.*?)'", urltemp.toString) CanalCam_URL.postUpdate("https://" + canalcamurl.toString) Garage_CC_URI.sendCommand(CanalCam_URL.state.toString) end