[Python] Using Selenium to download a segment of a JW Player Live Stream

Discussão em 'Python' iniciado por Stack, Dezembro 1, 2024.

  1. Stack

    Stack Membro Participativo

    I'm trying to write a python script using selenium to download 60s (arbitrary) of a live video feed (through a JW Player). A screen recording of sorts would be an acceptable solution (if limited to the frame the video is on) but a straight download would be preferable.

    The live stream is behind a login, so I have a script which logs in and tries to load the video.

    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.common.by import By
    from selenium.webdriver.chrome.options import Options
    import time

    options = webdriver.ChromeOptions()
    options.add_experimental_option("detach", True)

    driver = webdriver.Chrome(options=options)

    driver.get("https://magicseaweed.com/account/login/?dest=%2FLive-Whitesands-Webcam%2F245%2F")

    email = driver.find_element(By.XPATH, '//*[@id="msw-js-user-login-tab"]/form/div[2]/input')
    email.clear()
    email.send_keys("***@gmail.com")

    pwd = driver.find_element(By.XPATH, '//*[@id="msw-js-user-login-tab"]/form/div[3]/input')
    pwd.clear()
    pwd.send_keys("******")
    pwd.send_keys(Keys.RETURN)

    driver.find_element(By.XPATH, '//*[@id="msw-js-player245-stream"]').click()

    driver.close()


    I'm not sure why but

    driver.find_element(By.XPATH, '//*[@id="msw-js-player245-stream"]').click()


    doesn't start playing the video even though I was expecting it to.

    The xpath is the a div containing

    <video class="jw-video jw-reset" src="blob:https://magicseaweed.com/91b9d409-5ebf-4b93-a38a-8e6f0625f954"></video>


    but it also doesn't work by choosing the xpath of the above.

    So currently, I have the video on screen but can't start it playing and am not sure how to download or screen record 60s of it.

    Any help would be appreciated

    Continue reading...

Compartilhe esta Página