VideoHelp Forum



Support our site by donate $5 directly to us Thanks!!!

Try StreamFab Downloader and download streaming video from Netflix, Amazon!



+ Reply to Thread
Results 1 to 14 of 14
  1. I want to remotely obtain an m3u8 from this API (it has geoblocking outside of Spain).

    https://api.atresplayer.com/player/v1/live/5a6a165a7ed1a834493ebf6a

    I have managed to obtain it with PHP and Python (it gives an error from JavaScript). The problem is that the m3u8 is only valid for the server's IP, not the client's, so the solution with PHP is not valid. But with Python, I don't know how to access it from Google Chrome. I have tried to make the JS call to Python but I haven't been able to.

    Any ideas?
    Quote Quote  
  2. Feels Good Man 2nHxWW6GkN1l916N3ayz8HQoi's Avatar
    Join Date
    Jan 2024
    Location
    Pepe Island
    Search Comp PM
    So the server is in Spain and has no geoblocking problems, but the client isn't?
    --[----->+<]>.++++++++++++.---.--------.
    [*drm mass downloader: widefrog*]~~~~~~~~~~~[*how to make your own mass downloader: guide*]
    Quote Quote  
  3. Originally Posted by 2nHxWW6GkN1l916N3ayz8HQoi View Post
    So the server is in Spain and has no geoblocking problems, but the client isn't?
    The m3u8 contains a token that only works on one IP. Something like this: https://atres-live.atresmedia.com/6b550f7bab68261fdc56353d5f2588630c376881_ES_17079340...a3/master.m3u8
    What I want is for it to work on the client's IP.

    If I use PHP, the m3u8 only works with the server's IP.

    With JavaScript, I can't access the API, it throws an error.

    With Python, I can obtain the m3u8, but I don't know how to access it from the browser.
    Quote Quote  
  4. Feels Good Man 2nHxWW6GkN1l916N3ayz8HQoi's Avatar
    Join Date
    Jan 2024
    Location
    Pepe Island
    Search Comp PM
    Even if you get the m3u8 link from python, it's still tied to the server IP. What's the JS code and what's the error? Are you using a proxy? Another alternative that you could try, you could offer a endpoint server side that gets the m3u8 link from them, but doesn't return it. Instead it returns the content of that m3u8 link by using another get request on that token bound m3u8 link using the same IP it got bound to (the server). Basically acting as a middle man.
    --[----->+<]>.++++++++++++.---.--------.
    [*drm mass downloader: widefrog*]~~~~~~~~~~~[*how to make your own mass downloader: guide*]
    Quote Quote  
  5. Originally Posted by 2nHxWW6GkN1l916N3ayz8HQoi View Post
    Even if you get the m3u8 link from python, it's still tied to the server IP. What's the JS code and what's the error? Are you using a proxy? Another alternative that you could try, you could offer a endpoint server side that gets the m3u8 link from them, but doesn't return it. Instead it returns the content of that m3u8 link by using another get request on that token bound m3u8 link using the same IP it got bound to (the server). Basically acting as a middle man.
    I'm getting a 403 error with JS (the server is at my home in Spain). However, with PHP, it does allow obtaining the m3u8.

    JS

    <script>
    fetch('https://api.atresplayer.com/player/v1/live/5a6a165a7ed1a834493ebf6a')
    .then(response => response.json())
    .then(data => {
    const url = data.sourcesLive[0].src;
    })
    </script>

    PHP

    <?php
    $url = json_decode(file_get_contents('https://api.atresplayer.com/player/v1/live/5a6a165a7ed1a834493ebf6a'), true);
    $url = $url['sourcesLive'][0]['src'];
    echo $url;

    How does the "endpoint server" work?
    Quote Quote  
  6. Feels Good Man 2nHxWW6GkN1l916N3ayz8HQoi's Avatar
    Join Date
    Jan 2024
    Location
    Pepe Island
    Search Comp PM
    Well of course the php works since it is server side and the javascript doesn't since it's client side. You could research the idea of using fetch with proxies. Before I try and explain my idea, let's consider that you get the m3u8 link and you can do stuff with it client side. What is it you wanna do? Do you just want to play a stream client side or is there any other objective?
    --[----->+<]>.++++++++++++.---.--------.
    [*drm mass downloader: widefrog*]~~~~~~~~~~~[*how to make your own mass downloader: guide*]
    Quote Quote  
  7. I just want to play a stream client side using JW Player. Being able to use it from the mobile using data, etc.
    What is your idea? Nice avatar, by the way.
    Quote Quote  
  8. Feels Good Man 2nHxWW6GkN1l916N3ayz8HQoi's Avatar
    Join Date
    Jan 2024
    Location
    Pepe Island
    Search Comp PM
    Originally Posted by Babuino View Post
    I just want to play a stream client side using JW Player. Being able to use it from the mobile using data, etc.
    What is your idea? Nice avatar, by the way.
    First check if the contents of that m3u8 are geoblocked as well. Download a m3u8 on your server from spain and paste its contents here. How does the m3u8 look like? You should check if a random fragment from that m3u8 is geoblocked as well. Can the fragment be accessed client side?

    Do something like (this is pseudocode so don't copy-paste)
    Code:
    response = requests.get("https://api.atresplayer.com/player/v1/live/5a6a165a7ed1a834493ebf6a").text
    m3u8_url = parse_json(response)
    response = requests.get(m3u8_url)
    print(response)
    --[----->+<]>.++++++++++++.---.--------.
    [*drm mass downloader: widefrog*]~~~~~~~~~~~[*how to make your own mass downloader: guide*]
    Quote Quote  
  9. The m3u8 is geoblocked too: https://atres-live.atresmedia.com/6b550f7bab68261fdc56353d5f2588630c376881_ES_17079340...a3/master.m3u8

    "6b550f7bab68261fdc56353d5f2588630c376881" is the token, valid for only 1 IP.

    I've already have a Python script to extract the m3u8. The problem is that it's also not for the client side.
    Quote Quote  
  10. Feels Good Man 2nHxWW6GkN1l916N3ayz8HQoi's Avatar
    Join Date
    Jan 2024
    Location
    Pepe Island
    Search Comp PM
    Originally Posted by Babuino View Post
    The m3u8 is geoblocked too: https://atres-live.atresmedia.com/6b550f7bab68261fdc56353d5f2588630c376881_ES_17079340...a3/master.m3u8

    "6b550f7bab68261fdc56353d5f2588630c376881" is the token, valid for only 1 IP.

    I've already have a Python script to extract the m3u8. The problem is that it's also not for the client side.
    I know that. You made yourself clear up until now. What I am interested in is the content of that m3u8. A sample m3u8 would look like this:
    Code:
    #EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-TARGETDURATION:10
    #EXT-X-MEDIA-SEQUENCE:0
    #EXTINF:10.000000,
    fragment_0.ts
    #EXTINF:10.000000,
    fragment_1.ts
    #EXTINF:10.000000,
    fragment_2.ts
    #EXTINF:10.000000,
    fragment_3.ts
    #EXTINF:10.000000,
    fragment_4.ts
    #EXTINF:10.000000,
    fragment_5.ts
    #EXTINF:10.000000,
    fragment_6.ts
    #EXTINF:10.000000,
    fragment_7.ts
    #EXT-X-ENDLIST
    What I wanna know is, are these fragments geoblocked as well? Or do they point somewhere else entirely with different URLs that aren't geoblocked.
    --[----->+<]>.++++++++++++.---.--------.
    [*drm mass downloader: widefrog*]~~~~~~~~~~~[*how to make your own mass downloader: guide*]
    Quote Quote  
  11. I'm not sure if the .ts are geo-blocked. I can download them using VPN: https://atres-live.atresmedia.com/6b550f7bab68261fdc56353d5f2588630c376881_ES_17079340...1-170794477.ts
    Perhaps I could generate an m3u8 with those .ts files or something like that. Was that your idea? In that case, I suppose I could do something with PHP.

    Edit: I've created an m3u8 with .ts files, and it only works locally. In fact, they contain the same token.
    Last edited by Babuino; 14th Feb 2024 at 15:36.
    Quote Quote  
  12. Feels Good Man 2nHxWW6GkN1l916N3ayz8HQoi's Avatar
    Join Date
    Jan 2024
    Location
    Pepe Island
    Search Comp PM
    Originally Posted by Babuino View Post
    It seems the .ts are not geo-blocked. I can download it using VPN: https://atres-live.atresmedia.com/6b550f7bab68261fdc56353d5f2588630c376881_ES_17079340...1-170794477.ts
    Perhaps I could generate an m3u8 with those .ts files or something like that. Was that your idea? In that case, I suppose I could do something with PHP.
    My original idea was designed for worst case when the fragment ts were geoblocked as well with that token of yours. It basically turns your spain server into a proxy. Consider this. Whenever a m3u8 is played on a page it does a series of GET requests. GET .m3u8 file. GET first fragment, GET second fragment and so on and on.

    If you were to design a server api that has no problem with geoblocking you could do it like this. (python + flask for showcase, you can write it in whatever you are used to)
    Code:
    import requests
    from flask import Flask, request
    
    app = Flask(__name__)
    
    
    # this acts as a proxy to get the main m3u8
    @app.route('/get_m3u8', methods=['GET'])
    def get_m3u8():
        response = requests.get("https://api.atresplayer.com/player/v1/live/5a6a165a7ed1a834493ebf6a")  # or whatever link you have
        m3u8_url = m3u8_parse(response)
        m3u8_content = requests.get(m3u8_url)
        m3u8_content = m3u8_modify(m3u8_content)
        return m3u8_content
    
    
    def m3u8_parse(response_json):
        # here you extract your m3u8 from that json
        # example: https://atres-live.atresmedia.com/6b550f7bab68261fdc56353d5f2588630c376881_ES_1707934082_1707962822/h264leg/live/antena3/master.m3u8
        pass
    
    
    def m3u8_modify(m3u8_content):
        # if each fragment was geoblocked, you make a URL that points to the second endpoint of your flask API
        # example: your_python_server/get_fragment/fragment_1.ts
        # this endpoint will obtain the content of that ts fragment because it is not geoblocked here
        # for each fragment do this URL modification
        pass
    
    
    # this acts as a proxy to get the content of each fragment
    @app.route('/get_fragment/<path:fragment>', methods=['GET'])
    def get_fragment(fragment):
        base_url = request.args.get('base_url')
        fragment_url = f"{base_url}/{fragment}"
        fragment_content = requests.get(fragment_url)
        return fragment_content
    
    
    if __name__ == '__main__':
        app.run()
    This code is just a sketch. If you don't understand the basic idea behind it then just ignore what I said up until now. You could try the vpn idea in php if you are familiar with it.
    Last edited by 2nHxWW6GkN1l916N3ayz8HQoi; 14th Feb 2024 at 15:48.
    --[----->+<]>.++++++++++++.---.--------.
    [*drm mass downloader: widefrog*]~~~~~~~~~~~[*how to make your own mass downloader: guide*]
    Quote Quote  
  13. ChatGPT also suggested me to use Python + Flask
    Thank you very much for your help, I'll take a look at your code.
    Quote Quote  



Similar Threads

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