mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-06 11:35:29 +00:00
fix audio film
This commit is contained in:
parent
71f7f42485
commit
128ab14993
@ -24,6 +24,17 @@ def get_iframe(id_title, domain):
|
||||
console.log(f"[red]Error: {req.status_code}")
|
||||
sys.exit(0)
|
||||
|
||||
def select_quality(json_win_param):
|
||||
|
||||
if json_win_param['token1080p']:
|
||||
return "1080p"
|
||||
elif json_win_param['token720p']:
|
||||
return "720p"
|
||||
elif json_win_param['token480p']:
|
||||
return "480p"
|
||||
else:
|
||||
return "360p"
|
||||
|
||||
def parse_content(embed_content):
|
||||
|
||||
# Parse parameter from req embed content
|
||||
@ -34,7 +45,7 @@ def parse_content(embed_content):
|
||||
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)
|
||||
return json.loads(json_win_video), json.loads(json_win_param), select_quality(json.loads(json_win_param))
|
||||
|
||||
def get_m3u8_url(json_win_video, json_win_param, render_quality):
|
||||
token_render = f"token{render_quality}"
|
||||
@ -50,25 +61,45 @@ def get_m3u8_key(json_win_video, json_win_param, title_name, token_render):
|
||||
else:
|
||||
console.log(f"[red]Error: {req.status_code}")
|
||||
sys.exit(0)
|
||||
|
||||
def get_m3u8_audio(json_win_video, json_win_param, title_name, token_render):
|
||||
req = requests.get(f'https://vixcloud.co/playlist/{json_win_video["id"]}', params={'token': json_win_param['token'], 'expires': json_win_param["expires"] }, headers={
|
||||
'referer': f'https://vixcloud.co/embed/{json_win_video["id"]}?token={json_win_param[token_render]}&title={title_name.replace(" ", "+")}&referer=1&expires={json_win_param["expires"]}'
|
||||
})
|
||||
|
||||
if req.ok:
|
||||
m3u8_cont = req.text.split()
|
||||
for row in m3u8_cont:
|
||||
if "audio" in str(row) and "ita" in str(row):
|
||||
return row.split(",")[-1].split('"')[-2]
|
||||
else:
|
||||
console.log(f"[red]Error: {req.status_code}")
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
# [func \ main]
|
||||
def main_dw_film(id_film, title_name, domain):
|
||||
|
||||
lower_title_name = str(title_name).lower()
|
||||
title_name = convert_utf8_name(lower_title_name) # ERROR LATIN 1 IN REQ WITH ò à ù ...
|
||||
|
||||
embed_content = get_iframe(id_film, domain)
|
||||
json_win_video, json_win_param = parse_content(embed_content)
|
||||
json_win_video, json_win_param, render_quality = parse_content(embed_content)
|
||||
|
||||
# Select first availability video quality
|
||||
if json_win_param['token1080p'] != "": render_quality = "1080p"
|
||||
elif json_win_param['token720p'] != "": render_quality = "720p"
|
||||
elif json_win_param['token480p'] != "": render_quality = "480p"
|
||||
else: render_quality = "360p"
|
||||
token_render = f"token{render_quality}"
|
||||
console.print(f"[blue]Quality select => [red]{render_quality}")
|
||||
|
||||
m3u8_url = get_m3u8_url(json_win_video, json_win_param, render_quality)
|
||||
m3u8_key = get_m3u8_key(json_win_video, json_win_param, title_name, token_render)
|
||||
|
||||
mp4_name = lower_title_name.replace("+", " ").replace(",", "")
|
||||
mp4_format = mp4_name + ".mp4"
|
||||
mp4_path = os.path.join("videos", mp4_format)
|
||||
|
||||
m3u8_url_audio = get_m3u8_audio(json_win_video, json_win_param, title_name, token_render)
|
||||
|
||||
if m3u8_url_audio != None:
|
||||
console.print("[blue]Use m3u8 audio => [red]True")
|
||||
|
||||
path_film = os.path.join("videos", lower_title_name.replace("+", " ").replace(",", "") + ".mp4")
|
||||
dw_m3u8(m3u8_url, None, m3u8_key, path_film)
|
||||
print("\n")
|
||||
dw_m3u8(m3u8_url, m3u8_url_audio, m3u8_key, mp4_path)
|
||||
|
@ -7,6 +7,17 @@ from Src.Util.Helper.console import console
|
||||
# General import
|
||||
import requests, sys
|
||||
|
||||
def domain_version():
|
||||
|
||||
req = requests.get("https://raw.githubusercontent.com/Ghost6446/Streaming_comunity_data/main/data.json")
|
||||
|
||||
if req.ok and requests.get(f"https://streamingcommunity.{req.json()['domain']}/").ok:
|
||||
return req.json()['domain'], req.json()['version']
|
||||
|
||||
else:
|
||||
console.log(f"[red]Error: {req.status_code}, new domain available")
|
||||
sys.exit(0)
|
||||
|
||||
def search(title_search, domain):
|
||||
|
||||
title_search = str(title_search).replace(" ", "+")
|
||||
|
@ -55,6 +55,17 @@ def get_iframe(tv_id, ep_id, domain, token):
|
||||
console.log(f"[red]Error: {req.status_code}")
|
||||
sys.exit(0)
|
||||
|
||||
def select_quality(json_win_param):
|
||||
|
||||
if json_win_param['token1080p']:
|
||||
return "1080p"
|
||||
elif json_win_param['token720p']:
|
||||
return "720p"
|
||||
elif json_win_param['token480p']:
|
||||
return "480p"
|
||||
else:
|
||||
return "360p"
|
||||
|
||||
def parse_content(embed_content):
|
||||
|
||||
# Parse parameter from req embed content
|
||||
@ -65,7 +76,7 @@ def parse_content(embed_content):
|
||||
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)
|
||||
return json.loads(json_win_video), json.loads(json_win_param), select_quality(json.loads(json_win_param))
|
||||
|
||||
def get_m3u8_url(json_win_video, json_win_param, render_quality):
|
||||
token_render = f"token{render_quality}"
|
||||
@ -97,17 +108,13 @@ def get_m3u8_audio(json_win_video, json_win_param, tv_name, n_stagione, n_ep, ep
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
# [func \ main]
|
||||
def dw_single_ep(tv_id, eps, index_ep_select, domain, token, tv_name, season_select, lower_tv_name):
|
||||
|
||||
console.print(f"[green]Download ep: [blue]{eps[index_ep_select]['n']} [green]=> [purple]{eps[index_ep_select]['name']}")
|
||||
embed_content = get_iframe(tv_id, eps[index_ep_select]['id'], domain, token)
|
||||
json_win_video, json_win_param = parse_content(embed_content)
|
||||
json_win_video, json_win_param, render_quality = parse_content(embed_content)
|
||||
|
||||
# Select first availability video quality for single ep
|
||||
if json_win_param['token1080p'] != "": render_quality = "1080p"
|
||||
elif json_win_param['token720p'] != "": render_quality = "720p"
|
||||
elif json_win_param['token480p'] != "": render_quality = "480p"
|
||||
else: render_quality = "360p"
|
||||
token_render = f"token{render_quality}"
|
||||
console.print(f"[blue]Quality select => [red]{render_quality}")
|
||||
|
||||
@ -123,6 +130,7 @@ def dw_single_ep(tv_id, eps, index_ep_select, domain, token, tv_name, season_sel
|
||||
if m3u8_url_audio != None:
|
||||
console.print("[blue]Use m3u8 audio => [red]True")
|
||||
|
||||
print("\n")
|
||||
dw_m3u8(m3u8_url, m3u8_url_audio, m3u8_key, mp4_path)
|
||||
|
||||
def main_dw_tv(tv_id, tv_name, version, domain):
|
||||
@ -131,20 +139,29 @@ def main_dw_tv(tv_id, tv_name, version, domain):
|
||||
|
||||
lower_tv_name = str(tv_name).lower()
|
||||
tv_name = convert_utf8_name(lower_tv_name) # ERROR LATIN 1 IN REQ WITH ò à ù ...
|
||||
console.print(f"[blue]Season find: [red]{get_info_tv(tv_id, tv_name, version, domain)}")
|
||||
season_select = msg.ask("\n[green]Insert season number: ")
|
||||
|
||||
eps = get_info_season(tv_id, tv_name, domain, version, token, season_select)
|
||||
num_season_find = get_info_tv(tv_id, tv_name, version, domain)
|
||||
console.print(f"[blue]Season find: [red]{num_season_find}")
|
||||
season_select = int(msg.ask("\n[green]Insert season number: "))
|
||||
|
||||
for ep in eps:
|
||||
console.print(f"[green]Ep: [blue]{ep['n']} [green]=> [purple]{ep['name']}")
|
||||
index_ep_select = str(msg.ask("\n[green]Insert ep [red]number [green]or [red](*) [green]to download all ep: "))
|
||||
if 1 <= season_select <= num_season_find:
|
||||
eps = get_info_season(tv_id, tv_name, domain, version, token, season_select)
|
||||
|
||||
if index_ep_select != "*":
|
||||
index_ep_select = int(index_ep_select) - 1
|
||||
dw_single_ep(tv_id, eps, index_ep_select, domain, token, tv_name, season_select, lower_tv_name)
|
||||
for ep in eps:
|
||||
console.print(f"[green]Ep: [blue]{ep['n']} [green]=> [purple]{ep['name']}")
|
||||
index_ep_select = str(msg.ask("\n[green]Insert ep [red]number [green]or [red](*) [green]to download all ep: "))
|
||||
|
||||
if index_ep_select != "*":
|
||||
if 1 <= int(index_ep_select) <= len(eps):
|
||||
index_ep_select = int(index_ep_select) - 1
|
||||
dw_single_ep(tv_id, eps, index_ep_select, domain, token, tv_name, season_select, lower_tv_name)
|
||||
else:
|
||||
console.print("[red]Wrong index for ep")
|
||||
|
||||
else:
|
||||
for ep in eps:
|
||||
dw_single_ep(tv_id, eps, int(ep['n'])-1, domain, token, tv_name, season_select, lower_tv_name)
|
||||
print("\n")
|
||||
|
||||
else:
|
||||
for ep in eps:
|
||||
dw_single_ep(tv_id, eps, int(ep['n'])-1, domain, token, tv_name, season_select, lower_tv_name)
|
||||
print("\n")
|
||||
console.print("[red]Wrong index for season")
|
||||
|
@ -1,5 +1,5 @@
|
||||
__title__ = 'Streaming_community'
|
||||
__version__ = 'v0.8.0'
|
||||
__version__ = 'v0.8.1'
|
||||
__author__ = 'Ghost6446'
|
||||
__description__ = 'A command-line program to download film'
|
||||
__license__ = 'MIT License'
|
||||
|
@ -20,5 +20,4 @@ def merge_ts_files(video_path, audio_path, output_path):
|
||||
subprocess.run(ffmpeg_command, check=True, stderr=subprocess.PIPE)
|
||||
return True
|
||||
except subprocess.CalledProcessError as e:
|
||||
#print(f"Failed convert: {video_path} \ {audio_path} to {output_path}")
|
||||
return False
|
@ -32,9 +32,6 @@ class M3U8Downloader:
|
||||
self.m3u8_audio = m3u8_audio
|
||||
self.key = key
|
||||
self.output_filename = output_filename
|
||||
if output_filename == None:
|
||||
console.log(f"Cant pass None as output file name")
|
||||
sys.exit(0)
|
||||
|
||||
self.segments = []
|
||||
self.segments_audio = []
|
||||
@ -118,9 +115,9 @@ class M3U8Downloader:
|
||||
|
||||
if not there_is_audio(path_test_ts_file):
|
||||
self.download_audio = True
|
||||
console.log("[cyan]=> Make req to get video and audio file")
|
||||
#console.log("[yellow]=> Make req to get video and audio file")
|
||||
|
||||
console.log("[cyan]=> Download audio")
|
||||
#console.log("[yellow]=> Download audio")
|
||||
os.remove(path_test_ts_file)
|
||||
|
||||
def decrypt_ts(self, encrypted_data):
|
||||
|
21
run.py
21
run.py
@ -9,13 +9,12 @@ from Src.Util.Helper.console import console, msg
|
||||
from Src.Upload.update import main_update
|
||||
|
||||
# General import
|
||||
import sys, requests
|
||||
import sys
|
||||
|
||||
|
||||
# Variable
|
||||
json_data = requests.get("https://raw.githubusercontent.com/Ghost6446/Streaming_comunity_data/main/data.json").json()
|
||||
domain = json_data['domain']
|
||||
site_version = json_data['version']
|
||||
domain, site_version = Page.domain_version()
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@ -32,13 +31,17 @@ def main():
|
||||
console.print(f"[yellow]{i} [white]-> [green]{db_title[i]['name']} [white]- [cyan]{db_title[i]['type']}")
|
||||
index_select = int(msg.ask("\n[blue]Index to download: "))
|
||||
|
||||
if db_title[index_select]['type'] == "movie":
|
||||
console.print(f"[green]\nMovie select: {db_title[index_select]['name']}")
|
||||
download_film(db_title[index_select]['id'], db_title[index_select]['name'].replace(" ", "+"), domain)
|
||||
if 0 <= index_select <= len(db_title)-1:
|
||||
if db_title[index_select]['type'] == "movie":
|
||||
console.print(f"[green]\nMovie select: {db_title[index_select]['name']}")
|
||||
download_film(db_title[index_select]['id'], db_title[index_select]['name'].replace(" ", "+"), domain)
|
||||
|
||||
else:
|
||||
console.print(f"[green]\nTv select: {db_title[index_select]['name']}")
|
||||
download_tv(db_title[index_select]['id'], db_title[index_select]['name'].replace(" ", "+"), site_version, domain)
|
||||
|
||||
else:
|
||||
console.print(f"[green]\nTv select: {db_title[index_select]['name']}")
|
||||
download_tv(db_title[index_select]['id'], db_title[index_select]['name'].replace(" ", "+"), site_version, domain)
|
||||
console.print("[red]Wrong index for selection")
|
||||
|
||||
console.print("\n[red]Done")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user