I have the following HTML code:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body >
<iframe id="pic" src="http://rtsp.me/embed/883assBN/" width="450" height="254" frameborder="0" scrolling="no"></iframe>
</body>
</html>
When the page loads there is a play button that when it is pressed it starts playing a video. When it is pressed on the chrome network tab there is a GET request with the following URL : " https://frn.rtsp.me/xAbXuzHiF6P3Hi8P7fK4_A/1598176697/hls/883assBN.m3u8 " . The problem is after /frn.rtsp.me the sentences are being dynamically changed over some period of time for example :
https://frn.rtsp.me/XXX/XXX/hls/883assBN.m3u8
and I cannot obtain the new ones without using the provided HTML code and check the get requests in Chrome. My goal is to play the m3u8 video in a exoplayer on a Android device. How can I view the get requests there from a webView? Or is there any other way to obtain the m3u8 playlist?
Here is my solution:
val embedUrl = "https://rtsp.me/embed/883assBN/"
try {
val html: Connection.Response = Jsoup.connect(embedUrl).execute()
val statusCode = html.statusCode()
if (statusCode == 200) {
val dok: Document = Jsoup.parse(html.body(), embedUrl)
val scripts : Elements = dok.getElementsByTag("script")
val urlScript : String = scripts.last().toString()
val start_idx = urlScript.indexOf("https://")
val end_idx = urlScript.indexOf(";")
var tmp = urlScript.substring(start_idx,end_idx)
val result = tmp.replace("\"","")
}
} catch (e: IOException) {
e.printStackTrace()
}