Spaces:
Paused
Paused
File size: 4,597 Bytes
87b750e df2483b 278aea7 59ea086 6f619f8 df2483b 87b750e 331094b 87b750e f506922 87b750e 12966ea 87b750e 12966ea dc9da24 19e59fd dc9da24 8eaf3c2 dc9da24 87b750e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
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/<path:segment>', 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)
|