VideoHelp Forum
+ Reply to Thread
Results 1 to 2 of 2
Thread
  1. Hi all.

    I am at the end of tether here, I have been struggling with this for the whole day, I am using ChatGPT to assist me, but it keeps on messing the code up.


    I want to build a script which will automatically download videos from screenocean.com I can do it all manually, but I want to build an all in one type solution.

    To do this, my plan is to copy the video URL on the script, it them will retrieve the master m3u8 file, then it will hand it over to yt-dlp to construct the relevant segments.

    I've got it to ask for the URL, but as soon as I click enter, it says m3u8 not found.

    here is my script - or at least the one which has something working

    import requests
    import re
    from bs4 import BeautifulSoup

    def extract_master_playlist_url(url):
    try:
    # Make a GET request to the provided URL
    response = requests.get(url)
    response.raise_for_status() # Raise an exception for 4xx/5xx status codes

    # Parse the HTML content
    soup = BeautifulSoup(response.content, 'html.parser')

    # Find all script tags
    script_tags = soup.find_all('script')

    # Initialize variables to store results
    script_content = None
    playlist_url = None

    # Loop through script tags to find relevant JavaScript snippet
    for script_tag in script_tags:
    if script_tag.string:
    script_content = script_tag.string

    # Use regex to find the .m3u8 URL within iwPlayer.options["ImagenPlayer"].url
    match = re.search(r'iwPlayer\.options\["ImagenPlayer"\]\s*=\s*{\s*url\s*:\s*["\'](https?:\/\/[^"\']+\.(?:m3u8)[^"\']*)["\']', script_content)
    if match:
    playlist_url = match.group(1)
    break

    if playlist_url:
    return playlist_url
    else:
    return "No .m3u8 URL found in JavaScript."

    except requests.exceptions.RequestException as e:
    return f"Error fetching URL: {str(e)}"

    if __name__ == "__main__":
    # Ask user to input the URL
    video_url = input("Enter the URL of the video: ").strip()

    # Call function to extract master playlist URL
    playlist_url = extract_master_playlist_url(video_url)

    # Write results to log.txt
    with open('log.txt', 'w') as f:
    f.write(f"URL Entered: {video_url}\n")
    f.write(f"Result: {playlist_url}\n")
    f.write("\nHTML Content:\n")
    f.write(BeautifulSoup(requests.get(video_url).cont ent, 'html.parser').prettify())

    if playlist_url.startswith("http"):
    print(f"Master Playlist URL: {playlist_url}")
    else:
    print(f"Error: {playlist_url}")

    print("Results have been exported to log.txt")

    Log file reveals

    URL Entered: https://licensing.screenocean.com/record/231850
    Result: No .m3u8 URL found.

    but I go further down into the log it becomes clear that the m3u8 url is there {"url":"https:\/\/licensingmediascreenocean.imagencloud.com\/storage\/v1\/hls\/0x060a2b340101010201010f1213194b64ec55350373810580 04f2000D3A2029EF.m3u8","signature":"?sig=g3X1jL0X5 YijTcFVXSzXBhkzffvVxsFUdSIp8rAWTHs&d=1&et=17204276 14",
    it's just skipping past it.

    If anyone is able to assist me, it will be greatly appreciated.

    I haven't yet got to the part which sends to ffmpg or YT-DLP for processing, this is simply the first part which generates the master URL from the video URL, as decided to program the parts separately.

    Thanks guys
    Quote Quote  



Similar Threads

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