M3u8 scrāper using python

jimyjim

Honorary Poster
A SIMPLE MOVIE M3U8 SCRĀPER (TESTED ON VIDSTORM.RU)

just got bored kaya gumawa ng mga ganito, kayo na bahala mag experiment 🤣

Rich (BB code):
{"data":{"stream":"https://scrennnifu.click/movie/tt4123432/playlist.m3u8"},"success":true}


Python:
# app.py
# free source by: jimyjim
# scrape: https://vidstorm.ru/movie/338953


# yourlink.com/scrape?url=vidstorm_link

# THIS IS IMPORTANT:

# flask
# flask-cors
# playwright
# gunicorn


import time
import os
from flask import Flask, request, jsonify
from flask_cors import CORS
from playwright.sync_api import sync_playwright

app = Flask(__name__)
CORS(app)

playwright = sync_playwright().start()

browser = playwright.chromium.launch(
    headless=True,
    args=[
        "--no-sandbox",
        "--disable-setuid-sandbox",
        "--disable-dev-shm-usage"
    ]
)

def super_scraper(target_url):
    results = {}
 
    context = browser.new_context(
        user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/124.0.0.0 Safari/537.36"
    )

    page = context.new_page()

    def handle_response(res):
        if ".m3u8" in res.url and ("playlist" in res.url or "index" in res.url):
            if "stream" not in results:
                results["stream"] = res.url
                print(f"Captured: {res.url}")

    page.on("response", handle_response)

    try:
        page.goto(target_url, wait_until="domcontentloaded", timeout=90000)
        time.sleep(5)

    except Exception as e:
        print(f"Scraper Error: {e}")

    finally:
        context.close()

    return results


@app.route('/')
def health_check():
    return "200", 200


@app.route('/scrape')
def api_scrape():
    url = request.args.get('url')

    if not url:
        return jsonify({"error": "Missing url"}), 400

    try:
        data = super_scraper(url)
        return jsonify({"success": True, "data": data})
    except Exception as e:
        return jsonify({"error": str(e)})


if __name__ == "__main__":
    port = int(os.environ.get("PORT", 5000))
    app.run(host="0.0.0.0", port=port)
 
bat ganito response nya ts?
{"error":"cannot switch to a different thread"}
try mo lagay to sa taas
def super_scraper(target_url):
results = {}

remove mo to
playwright = sync_playwright().start()
browser = playwright.chromium.launch(...)

change mo ng ganito
sync_playwright() as p:
browser = p.chromium.launch(...)

etong line : time.sleep(5)
change mo sa : page.wait_for_timeout(5000)
 
try mo lagay to sa taas
def super_scraper(target_url):
results = {}

remove mo to
playwright = sync_playwright().start()
browser = playwright.chromium.launch(...)

change mo ng ganito
sync_playwright() as p:
browser = p.chromium.launch(...)

etong line : time.sleep(5)
change mo sa : page.wait_for_timeout(5000)
thanks ts, gumagana na. may na test ka na rin bang ibang sites?
 
🤦🤦
{
"data": {
"count": 2,
"stream": "You do not have permission to view the full content of this post. Log in or register now.",
"streams": [
"You do not have permission to view the full content of this post. Log in or register now.",
"You do not have permission to view the full content of this post. Log in or register now."
]
},
"elapsed": 20.64,
"success": true,
"url": "You do not have permission to view the full content of this post. Log in or register now."
}
 

About this Thread

  • 9
    Replies
  • 428
    Views
  • 7
    Participants
Last reply from:
STAR OF VENUS

Online now

Members online
1,316
Guests online
12,751
Total visitors
14,067

Forum statistics

Threads
2,335,065
Posts
29,281,710
Members
1,135,810
Latest member
prozender
Back
Top