• 0 Posts
  • 1 Comment
Joined 6 months ago
cake
Cake day: May 3rd, 2024

help-circle
  • I’ve been doing this with Selenium+SeleniumWire in Python. Here’s a basic script that will open a (Selenium) Firefox instance, load the URL passed in, wait for you to click through the various popups etc. and shell out to yt-dlp to download the m3u8. Requires Python, Firefox, and yt-dlp. I don’t see any reason it wouldn’t work on platforms other than Linux, but I haven’t tested at all. It could be updated to click through the play button/popups automatically but I cbf.

    Script
    #!/usr/bin/env python3
    import sys
    import threading
    import subprocess
    import selenium.webdriver
    from seleniumwire import webdriver
    
    firefox_opts = selenium.webdriver.FirefoxOptions()
    b = webdriver.Firefox(options = firefox_opts)
    
    done = threading.Event()
    cmdline = None
    
    def res_interceptor(req, res) -> None:
        global cmdline
        if req.url.endswith('master.m3u8'):
            headers = dict(req.headers)
            cmdline = ['yt-dlp', '--referer', headers.get('referer', ''), req.url]
            done.set()
    
    b.response_interceptor = res_interceptor
    b.get(sys.argv[1])
    done.wait()
    b.quit()
    assert cmdline is not None
    print(f"Command line: {' '.join(cmdline)}")
    subprocess.run(cmdline)
    
    Usage

    Install Python packages:

    $ pip install selenium selenium-wire blinker==1.7.0
    

    Run the script (redacted example output):

    $ python ./getm3u.py 'https://vidsrc.me/embed/[-]'
    Command line: yt-dlp --referer https://[-].com/ https://tmstr.[-].com/stream_new/d6BoyFydhIoAEakvYTGZHhYA7A9aEkwpA1SDsb1Xxd3fYFxxaPzUvIost8zBAjouTHLFNGFwRy/master.m3u8
    [generic] Extracting URL: https://tmstr.[-].com/stream_new/d6BoyFydhIoAEakvYTGZHhYA7A9aEkwpA1SDsb1Xxd3fYFxxaPzUvIost8zBAjouTHLFNGFwRy/master.m3u8
    [generic] master: Downloading webpage
    [generic] master: Downloading m3u8 information
    [info] master: Downloading 1 format(s): 2701
    [hlsnative] Downloading m3u8 manifest
    WARNING: Live HLS streams are not supported by the native downloader. If this is a livestream, please add "--downloader ffmpeg --hls-use-mpegts" to your command
    [hlsnative] Total fragments: 955
    [download] Destination: master [master].mp4
    [download]   0.7% of ~   2.35GiB at  989.83KiB/s ETA 34:15 (frag 7/955)
    

    If code isn’t your thing OP I’d be happy to run it on your URL and send the downloaded file over Matrix or something.