...
+ Reply to Thread
Results 1 to 16 of 16
-
Interesting challenge
OP asked
https://rotana.net/en/channels middle east ip require
m3u8 has token
HTML Code:
https://rotananet.hibridcdn.net/rotana/khaleejiya_abr/token=p=54~e=1712824654~h=cc0ae9.../playlist.m3u8
looking for assistance to generate a new link from its API (not downloading) using python, but I
couldn't figure out how this website generates the link
The way the site hid the m3u8 was quite interesting. The m3u8 is buried within a json string the was converted to base64 and then split into numerous parts.
I thought that I would share how to obtain the m3u8.
I decided to concentrate onCode:https://rotana.net/ar/channels?tz=240/channels#/live/rotana_LBC
1) useCode:curl -ks "https://hiplayer.hibridcdn.net/l/rotana-lbc"
2) Now the segments have to be isolated. Use sed to isolate the segments. Break the data at o= and then at .join
Code:sed -e "s#o=#\n#g" | sed -e "s#.join#\n.join#"
3) the data segments start with ey. Use grep to capture it
Code:grep "ey"
4) the data is a very long array, delimited by ' enclosed by [] and separated by ,
Use tr to delete these from the multiple base64 sub strings
Code:tr -d [',]
5) This leaves a very long base64 string. Convert this to ascii using openssl
Code:openssl base64 -A -d
6) This results in a json string containing the required m3u8. Extract the m3u8 with jq
Code:jq -r .streamUrl
7) At this point the stream can be copied or restreamed. Restream with VLC using
Code:xargs vlc
Complete code
Code:curl -ks "https://hiplayer.hibridcdn.net/l/rotana-lbc" | sed -e "s#o=#\n#g" | sed -e "s#.join#\n.join#" | grep "ey" | tr -d [',] | openssl base64 -A -d | jq -r .streamUrl | xargs vlc
This works for rotana-cinema ... modify for any other stream.
Code:curl -ks "https://hiplayer.hibridcdn.net/l/rotana-cinema" | sed -e "s#o=#\n#g" | sed -e "s#.join#\n.join#" | grep "ey" | tr -d [',] | openssl base64 -A -d | jq -r .streamUrl | xargs vlc
No disrespect to imr_saleh. https://rotana.net/en is an interesting site whose solution I thought should be shared. -
nice explanation jack, as usual
sad the OP can delete the original first post ... -
Creative as usual. Thank you for the explanation. Regarding deleting the first post, I thought no one was interested, but as long as you are interested, here is the method I came up with.
Code:import base64 import json import requests import re from datetime import datetime url = 'https://hiplayer.hibridcdn.net/l/rotana-classical?_=' timestamp = datetime.now().timestamp() final_time = int(timestamp * 1000) final_time_str = str(final_time) api = url + final_time_str response = requests.get(api) response_text = response.content.decode('utf-8') original_code = response_text start_pattern = "['" end_pattern = "'].join" start_index = original_code.find(start_pattern) + len(start_pattern) end_index = original_code.find(end_pattern, start_index) data_string = original_code[start_index:end_index] data_parts = data_string.split("','") single_line_data = ''.join(data_parts) decoded_data = base64.b64decode(single_line_data).decode('utf-8') data_dict = json.loads(decoded_data) m3u8_url = data_dict["streamUrl"] print(m3u8_url)
-
you write: Regarding deleting the first post, I thought no one was interested
the question is: why delete first post when have you find working solution ?
maybe your post it can useful to other members here on next future
so, good rule is cannot delete post if someone find solution. cheers -
-
You are correct. The site has changed and it is now pretty close to a normal set up.
Again I will concentrate lbclive, but you can modify to suite.
first we will curl the site to get the site code
Code:curl -ks "https://rotana.net/ar/channels?tz=240/channels"
easy way to do this is to insert line breaks whenever <a class="channel-link occurs in the output. we will use sed
Code:sed -e "s#.a class=.channel-link#\n\nclass channel-link#g"
Code:grep "lbclive"
We will capture the first occurrence of lbclive
Code:head -n1
This requires the use of awk with ' (\047) as the field separator. It is field 4
Code:awk "BEGIN{FS=\"\047\"} { print $4}"
The template looks like
Code:https://live.kwikmotion.com/rlbclive/rlbc.smil/playlist.m3u8?hdnts=exp=1717538064~acl=/rlbclive/rlbc.smil/*~hmac=724cedf1d87c4d2fc0b1efd42ea072f4f3435f5357bcab1be64bed8fb1b65460
We will insert it into the template using xargs
Here is the full code used not for downloading but for restream. Change it if you wish to download as you have already have the playlist.m3u8.
Code:curl -ks "https://rotana.net/ar/channels?tz=240/channels" | sed -e "s#.a class=.channel-link#\n\nclass channel-link#g" | grep "lbclive" | head -n1 | awk "BEGIN{FS=\"\047\"} { print $4}" | xargs -I{} ffplay -user_agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36" -referer "https://rotana.net/" -i "https://live.kwikmotion.com/rlbclive/rlbc.smil/playlist.m3u8?hdnts={}"
Last edited by jack_666; 4th Jun 2024 at 10:09.
-
what tool uses head -n1?
you are expected to use Google to expand your knowledge on such matters.
sed, grep, awk head and xargs are all extremely small portable programs from linux/unix ported to windows.
The very least you can do is google search for them in github.
Kindly read about cygwin64. -
Good morning,
I found this topic about rotana channels on kwikmotion.
In fact, the flows obtained are not readable and are blocked by 403 error.
In fact, you just need to obtain the m3u8 being broadcast live via the developer tools module of Edge or Chrome for example.
Here is a direct link to obtain the m3u8:
https://rotana.net/en/channels?tz=-120/channels#/live/rotana-lbc
This m3u link is not playable, despite the precision of Referer, User-Agent, Origin on browser or on VLC for example as follows:
Code:#EXTM3U #EXTINF:-1,Try channel #EXTVLCOPT:http-referrer=https://rotana.net/ #EXTVLCOPT:http-user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0 #EXTVLCOPT:http-header=Content-Type: application/x-mpegURL #EXTVLCOPT:http-header=Origin: https://rotana.net https://live.kwikmotion.com/rlbclive/rlbc.smil/rlbcpublish/rlbc_source/hdntl=exp=1721003578~acl=%2frlbclive%2frlbc.smil%2f*~data=hdntl~hmac=bc679d09467013c18eb73b40dac565cb2ed2057 3f17f3a2bd0eb727106a4e8d5/chunks.m3u8
Thank you very much -
You have to grab a fresh m3u8 url that haven't been fetched before. You can do that by blocking the request in devtools or making a python script to retrieve it.
[Attachment 80727 - Click to enlarge] -
Thank you aqzs
So i understand by the way, there is no way to use a same/unique generated link by several people or/and several times ?
Thanks again for you possible confirmation and help too if any
For example: tokened link inside of that main/master link can be used more than once, on several clients/people.
https://raw.githubusercontent.com/ipstreet312/freeiptv/master/ressources/btv/py/lci1.m3u8
So we can not do the same here for lbc, like lci channel.
Regards -
No for that website link seems to be only fetched once and return 403 after.
Those aren't the same stream plateform.
Similar Threads
-
Obtaining m3u8 from API by accessing with client IP
By Babuino in forum Video Streaming DownloadingReplies: 13Last Post: 14th Feb 2024, 16:07 -
Which editors have an API?
By apiman in forum ProgrammingReplies: 7Last Post: 1st Dec 2023, 11:31 -
Accessing api
By Sadomasochist in forum Video Streaming DownloadingReplies: 0Last Post: 12th Feb 2023, 10:59 -
api request
By birbal1 in forum Video Streaming DownloadingReplies: 5Last Post: 15th Apr 2022, 13:47 -
i need php script to grab/generate Auth token for m3u8 url (kodi or vlc)
By morif96 in forum Video Streaming DownloadingReplies: 0Last Post: 3rd Apr 2020, 21:41