from flask import Flask, request, Response import requests from bs4 import BeautifulSoup,SoupStrainer import re import json from urllib.parse import urlparse, parse_qs,unquote,quote User_Agent= "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 OPR/111.0.0.0" app = Flask(__name__) @app.route('/proxy/', methods=['GET']) def proxy_m3u8(segment): # Base URL of the original M3U8 base_url = "https://vixcloud.co/playlist/" # Append requested segment full_url = f"{base_url}{segment}?{request.query_string.decode('utf-8')}" # Fetch the requested content headers = {'User-Agent': 'Mozilla/5.0'} # Add headers if required resp = requests.get(full_url, headers=headers) # Return the content with the correct content type return Response(resp.content, content_type=resp.headers.get('Content-Type', 'application/vnd.apple.mpegurl')) def get_version(): #Extract the version from the main page of the site try: import json proxies = {} SC_DOMAIN = "prof" random_headers = {} random_headers['Referer'] = f"https://streamingcommunity.{SC_DOMAIN}/" random_headers['Origin'] = f"https://streamingcommunity.{SC_DOMAIN}" random_headers['User-Agent'] = User_Agent random_headers['user-agent'] = User_Agent base_url = f'https://streamingcommunity.{SC_DOMAIN}/richiedi-un-titolo' response = requests.get(base_url, headers=random_headers, allow_redirects = True, proxies = proxies) #Soup the response soup = BeautifulSoup(response.text, "lxml") # Extract version version = json.loads(soup.find("div", {"id": "app"}).get("data-page"))['version'] return version except Exception as e: print("Couldn't find the version",e) version = "65e52dcf34d64173542cd2dc6b8bb75b" return version @app.route('/test', methods=['GET']) def get_film(): tid ="9296" proxies = {} version = get_version() SC_DOMAIN = "prof" random_headers = {} random_headers['Referer'] = "https://streamingcommunity.buzz/" random_headers['Origin'] = "https://streamingcommunity.buzz" random_headers['x-inertia'] = "true" random_headers['x-inertia-version'] = version random_headers['User-Agent'] = User_Agent random_headers['user-agent'] = User_Agent #Access the iframe url = f'https://streamingcommunity.{SC_DOMAIN}/iframe/{tid}' response = requests.get(url, headers=random_headers, allow_redirects=True, proxies = proxies) iframe = BeautifulSoup(response.text, 'lxml') #Get the link of iframe iframe = iframe.find('iframe').get("src") #Get the ID containted in the src of iframe vixid = iframe.split("/embed/")[1].split("?")[0] parsed_url = urlparse(iframe) query_params = parse_qs(parsed_url.query) random_headers['Referer'] = f"https://streamingcommunity.{SC_DOMAIN}/" random_headers['Origin'] = f"https://streamingcommunity.{SC_DOMAIN}" random_headers['x-inertia'] = "true" random_headers['x-inertia-version'] = version random_headers['User-Agent'] = User_Agent random_headers['user-agent'] = User_Agent #Get real token and expires by looking at the page in the iframe, vixcloud/embed resp = requests.get(iframe, headers = random_headers, allow_redirects=True, proxies = proxies) soup= BeautifulSoup(resp.text, "lxml") script = soup.find("body").find("script").text token = re.search(r"'token':\s*'(\w+)'", script).group(1) expires = re.search(r"'expires':\s*'(\d+)'", script).group(1) quality = re.search(r'"quality":(\d+)', script).group(1) #Example url https://vixcloud.co/playlist/231315?b=1&token=bce060eec3dc9d1965a5d258dc78c964&expires=1728995040&rendition=1080p url = f'https://vixcloud.co/playlist/{vixid}.m3u8?token={token}&expires={expires}' if 'canPlayFHD' in query_params: canPlayFHD = 'h=1' url += "&h=1" if 'b' in query_params: b = 'b=1' url += "&b=1" ''' if quality == "1080": if "&h" in url: url = url elif "&b" in url and quality == "1080": url = url.replace("&b=1","&h=1") elif quality == "1080" and "&b" and "&h" not in url: url = url + "&h=1" else: url = url + f"&token={token}" ''' url720 = f'https://vixcloud.co/playlist/{vixid}.m3u8' url1 = quote(url) return Response(url,url1) if __name__ == '__main__': app.run(host='0.0.0.0', port=8000)