LoremPizza commited on
Commit
dc9da24
·
verified ·
1 Parent(s): 87b750e

Update test.py

Browse files
Files changed (1) hide show
  1. test.py +89 -0
test.py CHANGED
@@ -18,5 +18,94 @@ def proxy_m3u8(segment):
18
  # Return the content with the correct content type
19
  return Response(resp.content, content_type=resp.headers.get('Content-Type', 'application/vnd.apple.mpegurl'))
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  if __name__ == '__main__':
22
  app.run(host='0.0.0.0', port=8000)
 
18
  # Return the content with the correct content type
19
  return Response(resp.content, content_type=resp.headers.get('Content-Type', 'application/vnd.apple.mpegurl'))
20
 
21
+ def get_version():
22
+ #Extract the version from the main page of the site
23
+
24
+
25
+ try:
26
+ import json
27
+ proxies = {}
28
+ SC_DOMAIN = "prof"
29
+ random_headers = {}
30
+ random_headers['Referer'] = f"https://streamingcommunity.{SC_DOMAIN}/"
31
+ random_headers['Origin'] = f"https://streamingcommunity.{SC_DOMAIN}"
32
+ random_headers['User-Agent'] = User_Agent
33
+ random_headers['user-agent'] = User_Agent
34
+ base_url = f'https://streamingcommunity.{SC_DOMAIN}/richiedi-un-titolo'
35
+ response = requests.get(base_url, headers=random_headers, allow_redirects = True, proxies = proxies)
36
+ #Soup the response
37
+ soup = BeautifulSoup(response.text, "lxml")
38
+
39
+ # Extract version
40
+ version = json.loads(soup.find("div", {"id": "app"}).get("data-page"))['version']
41
+ return version
42
+ except Exception as e:
43
+ print("Couldn't find the version",e)
44
+ version = "65e52dcf34d64173542cd2dc6b8bb75b"
45
+ return version
46
+
47
+ @app.get("/")
48
+ def get_film():
49
+ tid ="9296"
50
+ proxies = {}
51
+ version = get_version()
52
+ SC_DOMAIN = "prof"
53
+ random_headers = {}
54
+ random_headers['Referer'] = "https://streamingcommunity.buzz/"
55
+ random_headers['Origin'] = "https://streamingcommunity.buzz"
56
+ random_headers['x-inertia'] = "true"
57
+ random_headers['x-inertia-version'] = version
58
+ random_headers['User-Agent'] = User_Agent
59
+ random_headers['user-agent'] = User_Agent
60
+ #Access the iframe
61
+ url = f'https://streamingcommunity.{SC_DOMAIN}/iframe/{tid}'
62
+ response = requests.get(url, headers=random_headers, allow_redirects=True, proxies = proxies)
63
+ iframe = BeautifulSoup(response.text, 'lxml')
64
+ #Get the link of iframe
65
+ iframe = iframe.find('iframe').get("src")
66
+ #Get the ID containted in the src of iframe
67
+ vixid = iframe.split("/embed/")[1].split("?")[0]
68
+ parsed_url = urlparse(iframe)
69
+ query_params = parse_qs(parsed_url.query)
70
+ random_headers['Referer'] = f"https://streamingcommunity.{SC_DOMAIN}/"
71
+ random_headers['Origin'] = f"https://streamingcommunity.{SC_DOMAIN}"
72
+ random_headers['x-inertia'] = "true"
73
+ random_headers['x-inertia-version'] = version
74
+ random_headers['User-Agent'] = User_Agent
75
+ random_headers['user-agent'] = User_Agent
76
+ #Get real token and expires by looking at the page in the iframe, vixcloud/embed
77
+ resp = requests.get(iframe, headers = random_headers, allow_redirects=True, proxies = proxies)
78
+ soup= BeautifulSoup(resp.text, "lxml")
79
+ script = soup.find("body").find("script").text
80
+ token = re.search(r"'token':\s*'(\w+)'", script).group(1)
81
+ expires = re.search(r"'expires':\s*'(\d+)'", script).group(1)
82
+ quality = re.search(r'"quality":(\d+)', script).group(1)
83
+ #Example url https://vixcloud.co/playlist/231315?b=1&token=bce060eec3dc9d1965a5d258dc78c964&expires=1728995040&rendition=1080p
84
+ url = f'https://vixcloud.co/playlist/{vixid}.m3u8?token={token}&expires={expires}'
85
+ if 'canPlayFHD' in query_params:
86
+ canPlayFHD = 'h=1'
87
+ url += "&h=1"
88
+ if 'b' in query_params:
89
+ b = 'b=1'
90
+ url += "&b=1"
91
+ '''
92
+ if quality == "1080":
93
+ if "&h" in url:
94
+ url = url
95
+ elif "&b" in url and quality == "1080":
96
+ url = url.replace("&b=1","&h=1")
97
+ elif quality == "1080" and "&b" and "&h" not in url:
98
+ url = url + "&h=1"
99
+ else:
100
+ url = url + f"&token={token}"
101
+ '''
102
+ url720 = f'https://vixcloud.co/playlist/{vixid}.m3u8'
103
+ url1 = quote(url)
104
+ return url,url1
105
+
106
+ if __name__ == "__main__":
107
+ import uvicorn
108
+ uvicorn.run(app, host="0.0.0.0", port=8000)
109
+
110
  if __name__ == '__main__':
111
  app.run(host='0.0.0.0', port=8000)