VideoHelp Forum




+ Reply to Thread
Results 1 to 16 of 16
  1. ...
    Last edited by imr_saleh; 12th Apr 2024 at 02:00.
    Quote Quote  
  2. .........
    Last edited by imr_saleh; 12th Apr 2024 at 02:00.
    Quote Quote  
  3. 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 on
    Code:
    https://rotana.net/ar/channels?tz=240/channels#/live/rotana_LBC
    but the technique can be implemented on any of the other streams.


    1) use
    Code:
    curl -ks "https://hiplayer.hibridcdn.net/l/rotana-lbc"
    to grab the data containing the numerous base64 string segments.


    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.
    Quote Quote  
  4. nice explanation jack, as usual

    sad the OP can delete the original first post ...
    Quote Quote  
  5. Originally Posted by jack_666 View Post
    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

    No disrespect to imr_saleh. https://rotana.net/en is an interesting site whose solution I thought should be shared.

    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)
    Quote Quote  
  6. 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
    Quote Quote  
  7. Originally Posted by imr_saleh View Post
    Originally Posted by jack_666 View Post
    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

    No disrespect to imr_saleh. https://rotana.net/en is an interesting site whose solution I thought should be shared.

    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)
    It doesn't work anymore.
    It seems that Rotana has made some modifications and changed its player from hiplayer to kwikmotion
    Quote Quote  
  8. 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"
    This will produce a lot of verbiage and we will need to filter out the data for lbc channel


    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"
    This will break the output data into smaller chunks that we can capture using grep.


    Code:
    grep "lbclive"
    We have now captured all references to lbclive (change lbclive to whatever you may desire)


    We will capture the first occurrence of lbclive


    Code:
     head -n1
    Now that block of data has the information that we require. We need this data ('exp=1717538064~acl=/rdramalive/rdrama.smil/*~hmac=b0012138191bbacee9e6c2baa72794ba8a7fc1f3e3c 3b600319b44ec323c8a98' )


    This requires the use of awk with ' (\047) as the field separator. It is field 4


    Code:
    awk "BEGIN{FS=\"\047\"} { print $4}"
    The main data has now been captured. We need to feed into the kwikmotion playlist template




    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={}"
    Convert to whatever language you feel most comfortable with.
    Last edited by jack_666; 4th Jun 2024 at 10:09.
    Quote Quote  
  9. wow jack, you're number one of rotana challenge !
    Quote Quote  
  10. Thanks lomero.

    I am just trying to help and hopefully teach.
    Quote Quote  
  11. Originally Posted by jack_666 View Post
    We will capture the first occurrence of lbclive

    Code:
     head -n1
    Thanks Jack but what tool uses head -n1?
    Quote Quote  
  12. 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.
    Quote Quote  
  13. 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
    What do you think could be the cause of the 403 error?
    Thank you very much
    Quote Quote  
  14. Member aqzs's Avatar
    Join Date
    Mar 2024
    Location
    Paris
    Search Comp PM
    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.
    Image
    [Attachment 80727 - Click to enlarge]
    Quote Quote  
  15. 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
    Quote Quote  
  16. Member aqzs's Avatar
    Join Date
    Mar 2024
    Location
    Paris
    Search Comp PM
    No for that website link seems to be only fetched once and return 403 after.
    Those aren't the same stream plateform.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!