-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
508 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# 3.12.23 -> 10.12.23 | ||
|
||
# Class import | ||
from Stream.util.headers import get_headers | ||
from Stream.util.console import console | ||
from Stream.util.m3u8 import dw_m3u8 | ||
|
||
# General import | ||
import requests, sys, re, json | ||
from bs4 import BeautifulSoup | ||
|
||
# [func] | ||
def get_iframe(id_title, domain): | ||
req_iframe = requests.get(url = f"https://streamingcommunity.{domain}/iframe/{id_title}", headers = { | ||
"User-agent": get_headers() | ||
}) | ||
|
||
url_embed = BeautifulSoup(req_iframe.text, "lxml").find("iframe").get("src") | ||
req_embed = requests.get(url_embed, headers = {"User-agent": get_headers()}).text | ||
return BeautifulSoup(req_embed, "lxml").find("body").find("script").text | ||
|
||
def parse_content(embed_content): | ||
|
||
# Parse parameter from req embed content | ||
win_video = re.search(r"window.video = {.*}", str(embed_content)).group() | ||
win_param = re.search(r"params: {[\s\S]*}", str(embed_content)).group() | ||
|
||
# Parse parameter to make read for json | ||
json_win_video = "{"+win_video.split("{")[1].split("}")[0]+"}" | ||
json_win_param = "{"+win_param.split("{")[1].split("}")[0].replace("\n", "").replace(" ", "") + "}" | ||
json_win_param = json_win_param.replace(",}", "}").replace("'", '"') | ||
return json.loads(json_win_video), json.loads(json_win_param) | ||
|
||
def get_m3u8_url(json_win_video, json_win_param): | ||
return f"https://vixcloud.co/playlist/{json_win_video['id']}?type=video&rendition=720p&token={json_win_param['token720p']}&expires={json_win_param['expires']}" | ||
|
||
def get_m3u8_key(json_win_video, json_win_param, title_name): | ||
req_key = requests.get('https://vixcloud.co/storage/enc.key', headers={ | ||
'referer': f'https://vixcloud.co/embed/{json_win_video["id"]}?token={json_win_param["token720p"]}&title={title_name.replace(" ", "+")}&referer=1&expires={json_win_param["expires"]}', | ||
}).content | ||
|
||
return "".join(["{:02x}".format(c) for c in req_key]) | ||
|
||
def main_dw_film(id_film, title_name, domain): | ||
|
||
embed_content = get_iframe(id_film, domain) | ||
json_win_video, json_win_param = parse_content(embed_content) | ||
m3u8_url = get_m3u8_url(json_win_video, json_win_param) | ||
m3u8_key = get_m3u8_key(json_win_video, json_win_param, title_name) | ||
|
||
dw_m3u8(m3u8_url, requests.get(m3u8_url, headers={"User-agent": get_headers()}).text, "", m3u8_key, str(title_name).replace("+", " ").replace(",", "") + ".mp4") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# 10.12.23 | ||
|
||
# Class import | ||
from Stream.util.headers import get_headers | ||
from Stream.util.console import console | ||
|
||
# General import | ||
import requests, json, sys | ||
from bs4 import BeautifulSoup | ||
|
||
def get_version(domain): | ||
|
||
try: | ||
r = requests.get(f'https://streamingcommunity.{domain}/', headers={ | ||
'Authority': f'streamingcommunity.{domain}', | ||
'User-Agent': get_headers(), | ||
}) | ||
soup = BeautifulSoup(r.text, "lxml") | ||
info_data_page = soup.find("div", {'id': 'app'}).attrs["data-page"] | ||
|
||
return json.loads(info_data_page)['version'] | ||
|
||
except: | ||
|
||
console.log("[red]UPDATE DOMANIN") | ||
sys.exit(0) | ||
|
||
|
||
def search(title_search, domain): | ||
|
||
title_search = str(title_search).replace(" ", "+") | ||
r = requests.get( | ||
url = f"https://streamingcommunity.{domain}/api/search?q={title_search}", | ||
headers = {"User-agent": get_headers()} | ||
) | ||
|
||
return [{'name': title['name'], 'type': title['type'], 'id': title['id']} for title in r.json()['data']] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# 3.12.23 -> 10.12.23 | ||
|
||
# Class import | ||
from Stream.util.headers import get_headers | ||
from Stream.util.console import console, msg, console_print | ||
from Stream.util.m3u8 import dw_m3u8 | ||
|
||
# General import | ||
import requests, sys, re, json | ||
from bs4 import BeautifulSoup | ||
|
||
# [func] | ||
def get_token(id_tv, domain): | ||
session = requests.Session() | ||
session.get(f"https://streamingcommunity.{domain}/watch/{id_tv}") | ||
return session.cookies['XSRF-TOKEN'] | ||
|
||
def get_info_tv(id_film, title_name, site_version, domain): | ||
r = requests.get(f"https://streamingcommunity.{domain}/titles/{id_film}-{title_name}", headers={ | ||
'X-Inertia': 'true', | ||
'X-Inertia-Version': site_version, | ||
'User-Agent': get_headers() | ||
}) | ||
|
||
return r.json()['props']['title']['seasons_count'] | ||
|
||
def get_info_season(tv_id, tv_name, domain, version, token, n_stagione): | ||
r = requests.get(f'https://streamingcommunity.{domain}/titles/{tv_id}-{tv_name}/stagione-{n_stagione}', headers={ | ||
'authority': f'streamingcommunity.{domain}', 'referer': f'https://streamingcommunity.broker/titles/{tv_id}-{tv_name}', | ||
'user-agent': get_headers(), 'x-inertia': 'true', 'x-inertia-version': version, 'x-xsrf-token': token, | ||
}) | ||
|
||
return [{'id': ep['id'], 'n': ep['number'], 'name': ep['name']} for ep in r.json()['props']['loadedSeason']['episodes']] | ||
|
||
def get_iframe(tv_id, ep_id, domain, token): | ||
r = requests.get(f'https://streamingcommunity.{domain}/iframe/{tv_id}', params={'episode_id': ep_id, 'next_episode': '1'}, cookies={'XSRF-TOKEN': token}, headers={ | ||
'referer': f'https://streamingcommunity.{domain}/watch/{tv_id}?e={ep_id}', | ||
'user-agent': get_headers() | ||
}) | ||
|
||
url_embed = BeautifulSoup(r.text, "lxml").find("iframe").get("src") | ||
req_embed = requests.get(url_embed, headers = {"User-agent": get_headers()}).text | ||
return BeautifulSoup(req_embed, "lxml").find("body").find("script").text | ||
|
||
def parse_content(embed_content): | ||
|
||
# Parse parameter from req embed content | ||
win_video = re.search(r"window.video = {.*}", str(embed_content)).group() | ||
win_param = re.search(r"params: {[\s\S]*}", str(embed_content)).group() | ||
|
||
# Parse parameter to make read for json | ||
json_win_video = "{"+win_video.split("{")[1].split("}")[0]+"}" | ||
json_win_param = "{"+win_param.split("{")[1].split("}")[0].replace("\n", "").replace(" ", "") + "}" | ||
json_win_param = json_win_param.replace(",}", "}").replace("'", '"') | ||
return json.loads(json_win_video), json.loads(json_win_param) | ||
|
||
def get_m3u8_url(json_win_video, json_win_param): | ||
return f"https://vixcloud.co/playlist/{json_win_video['id']}?type=video&rendition=720p&token={json_win_param['token720p']}&expires={json_win_param['expires']}" | ||
|
||
def get_m3u8_key_ep(json_win_video, json_win_param, tv_name, n_stagione, n_ep, ep_title): | ||
req_key = requests.get('https://vixcloud.co/storage/enc.key', headers={ | ||
'referer': f'https://vixcloud.co/embed/{json_win_video["id"]}?token={json_win_param["token720p"]}&title={tv_name.replace("-", "+")}&referer=1&expires={json_win_param["expires"]}&description=S{n_stagione}%3AE{n_ep}+{ep_title.replace(" ", "+")}&nextEpisode=1', | ||
}).content | ||
|
||
return "".join(["{:02x}".format(c) for c in req_key]) | ||
|
||
def main_dw_tv(tv_id, tv_name, version, domain): | ||
|
||
token = get_token(tv_id, domain) | ||
|
||
tv_name = str(tv_name.replace('+', '-')).lower() | ||
console.log(f"[blue]Season find: [red]{get_info_tv(tv_id, tv_name, version, domain)}") | ||
season_select = msg.ask("[green]Insert season number: ") | ||
|
||
eps = get_info_season(tv_id, tv_name, domain, version, token, season_select) | ||
for ep in eps: | ||
console_print(f"[green]Ep: [blue]{ep['n']} [green]=> [purple]{ep['name']}") | ||
|
||
index_ep_select = int(msg.ask("[green]Insert ep number: ")) - 1 | ||
embed_content = get_iframe(tv_id, eps[index_ep_select]['id'], domain, token) | ||
json_win_video, json_win_param = parse_content(embed_content) | ||
m3u8_url = get_m3u8_url(json_win_video, json_win_param) | ||
m3u8_key = get_m3u8_key_ep(json_win_video, json_win_param, tv_name, season_select, index_ep_select+1, eps[index_ep_select]['name']) | ||
|
||
dw_m3u8(m3u8_url, requests.get(m3u8_url, headers={"User-agent": get_headers()}).text, "", m3u8_key, tv_name.replace("+", "_") + "_"+str(season_select)+"__"+str(index_ep_select+1) + ".mp4") | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# 17.09.2023 -> 3.12.23 | ||
|
||
# Import | ||
from rich.console import Console | ||
from rich.prompt import Prompt | ||
from rich import print as console_print | ||
|
||
# Variable | ||
msg = Prompt() | ||
console = Console() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# 3.12.23 -> 10.12.23 | ||
|
||
# Import | ||
from random_user_agent.user_agent import UserAgent | ||
from random_user_agent.params import SoftwareName, OperatingSystem | ||
|
||
# [func] | ||
def get_headers(): | ||
software_names = [SoftwareName.CHROME.value] | ||
operating_systems = [OperatingSystem.WINDOWS.value, OperatingSystem.LINUX.value] | ||
user_agent_rotator = UserAgent(software_names=software_names, operating_systems=operating_systems, limit=10) | ||
return user_agent_rotator.get_random_user_agent() |
Oops, something went wrong.