mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 20:15:24 +00:00
Migliorie per il codice (#45)
* Season range and all download * fix if/elif * fix if download all season * Refactor user input handling in main function now you can choose more than one movie or tv * Refactor file paths and create subdirectories for tv show now fill number season and episode to arrive to 2 characters * Update console print message in tv.py
This commit is contained in:
parent
fe687daf9d
commit
a6a6d55379
@ -134,9 +134,9 @@ def dw_single_ep(tv_id, eps, index_ep_select, domain, token, tv_name, season_sel
|
|||||||
m3u8_url = get_m3u8_url(json_win_video, json_win_param, render_quality)
|
m3u8_url = get_m3u8_url(json_win_video, json_win_param, render_quality)
|
||||||
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'], token_render)
|
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'], token_render)
|
||||||
|
|
||||||
mp4_name = f"{tv_name.replace('+', '_')}_S{str(season_select)}E{str(index_ep_select+1)}"
|
mp4_name = f"{tv_name.replace('+', '_')}_S{str(season_select).zfill(2)}E{str(index_ep_select+1).zfill(2)}"
|
||||||
mp4_format = mp4_name + ".mp4"
|
mp4_format = f"{mp4_name}.mp4"
|
||||||
mp4_path = os.path.join("videos", mp4_format)
|
mp4_path = os.path.join("videos",tv_name, mp4_format)
|
||||||
|
|
||||||
m3u8_url_audio = get_m3u8_playlist(json_win_video, json_win_param, tv_name, season_select, index_ep_select+1, eps[index_ep_select]['name'], token_render)
|
m3u8_url_audio = get_m3u8_playlist(json_win_video, json_win_param, tv_name, season_select, index_ep_select+1, eps[index_ep_select]['name'], token_render)
|
||||||
|
|
||||||
@ -150,9 +150,19 @@ def main_dw_tv(tv_id, tv_name, version, domain):
|
|||||||
token = get_token(tv_id, domain)
|
token = get_token(tv_id, domain)
|
||||||
|
|
||||||
num_season_find = get_info_tv(tv_id, tv_name, version, domain)
|
num_season_find = get_info_tv(tv_id, tv_name, version, domain)
|
||||||
console.print(f"[blue]Season find: [red]{num_season_find}")
|
console.print("\n[green]Insert season [red]number [yellow]or [red](*) [green]to download all seasons [yellow]or [red][1-2] [green]for a range of season")
|
||||||
season_select = int(msg.ask("\n[green]Insert season number: "))
|
console.print(f"\n[blue]Season find: [red]{num_season_find}")
|
||||||
|
season_select = str(msg.ask("\n[green]Insert season number: "))
|
||||||
|
if "[" in season_select:
|
||||||
|
start, end = map(int, season_select[1:-1].split('-'))
|
||||||
|
result = list(range(start, end + 1))
|
||||||
|
for n_season in result:
|
||||||
|
eps = get_info_season(tv_id, tv_name, domain, version, token, n_season)
|
||||||
|
for ep in eps:
|
||||||
|
dw_single_ep(tv_id, eps, int(ep['n'])-1, domain, token, tv_name, n_season)
|
||||||
|
print("\n")
|
||||||
|
elif season_select != "*":
|
||||||
|
season_select = int(season_select)
|
||||||
if 1 <= season_select <= num_season_find:
|
if 1 <= season_select <= num_season_find:
|
||||||
eps = get_info_season(tv_id, tv_name, domain, version, token, season_select)
|
eps = get_info_season(tv_id, tv_name, domain, version, token, season_select)
|
||||||
|
|
||||||
@ -185,3 +195,10 @@ def main_dw_tv(tv_id, tv_name, version, domain):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
console.print("[red]Wrong index for season")
|
console.print("[red]Wrong index for season")
|
||||||
|
else:
|
||||||
|
for n_season in range(1, num_season_find+1):
|
||||||
|
eps = get_info_season(tv_id, tv_name, domain, version, token, n_season)
|
||||||
|
for ep in eps:
|
||||||
|
dw_single_ep(tv_id, eps, int(ep['n'])-1, domain, token, tv_name, n_season)
|
||||||
|
print("\n")
|
||||||
|
|
||||||
|
@ -458,6 +458,8 @@ def download_m3u8(m3u8_playlist=None, m3u8_index = None, m3u8_audio=None, m3u8_s
|
|||||||
|
|
||||||
|
|
||||||
# Download m3u8 index, with segments
|
# Download m3u8 index, with segments
|
||||||
os.makedirs("videos", exist_ok=True)
|
# os.makedirs("videos", exist_ok=True)
|
||||||
|
path = output_filename.split("\\")
|
||||||
|
os.makedirs("\\".join(path[:-1]), exist_ok=True)
|
||||||
if log: console.log(f"[green]Dowload m3u8 from index [white]=> [purple]{m3u8_index}")
|
if log: console.log(f"[green]Dowload m3u8 from index [white]=> [purple]{m3u8_index}")
|
||||||
M3U8_Downloader(m3u8_index, m3u8_audio, key=key, output_filename=output_filename).start()
|
M3U8_Downloader(m3u8_index, m3u8_audio, key=key, output_filename=output_filename).start()
|
||||||
|
35
run.py
35
run.py
@ -41,8 +41,14 @@ def main():
|
|||||||
Page.display_search_results(db_title)
|
Page.display_search_results(db_title)
|
||||||
|
|
||||||
if len(db_title) != 0:
|
if len(db_title) != 0:
|
||||||
index_select = int(msg.ask("\n[blue]Index to download: "))
|
console.print(f"\n[blue]Total result: {len(db_title)}")
|
||||||
|
console.print(
|
||||||
|
"\n[green]Insert index [red]number [yellow]or [red][1-2] [green]for a range of movies/tv [yellow]or [red][1,3,5] [green]to select discontinued movie/tv"
|
||||||
|
)
|
||||||
|
console.print("\n[red]In case of tv show you will have to choose season and episode to download")
|
||||||
|
index_select = str(msg.ask("\n[blue]Index to download: "))
|
||||||
|
if index_select.isnumeric():
|
||||||
|
index_select = int(index_select)
|
||||||
if 0 <= index_select <= len(db_title) - 1:
|
if 0 <= index_select <= len(db_title) - 1:
|
||||||
selected_title = db_title[index_select]
|
selected_title = db_title[index_select]
|
||||||
|
|
||||||
@ -52,7 +58,30 @@ def main():
|
|||||||
else:
|
else:
|
||||||
console.print(f"[green]\nTv select: {selected_title['name']}")
|
console.print(f"[green]\nTv select: {selected_title['name']}")
|
||||||
download_tv(selected_title['id'], selected_title['slug'], site_version, domain)
|
download_tv(selected_title['id'], selected_title['slug'], site_version, domain)
|
||||||
|
else:
|
||||||
|
console.print("[red]Wrong index for selection")
|
||||||
|
elif "[" in index_select:
|
||||||
|
if "-" in index_select:
|
||||||
|
start, end = map(int, index_select[1:-1].split('-'))
|
||||||
|
result = list(range(start, end + 1))
|
||||||
|
for n in result:
|
||||||
|
selected_title = db_title[n]
|
||||||
|
if selected_title['type'] == "movie":
|
||||||
|
console.print(f"[green]\nMovie select: {selected_title['name']}")
|
||||||
|
download_film(selected_title['id'], selected_title['slug'], domain)
|
||||||
|
else:
|
||||||
|
console.print(f"[green]\nTv select: {selected_title['name']}")
|
||||||
|
download_tv(selected_title['id'], selected_title['slug'], site_version, domain)
|
||||||
|
elif "," in index_select:
|
||||||
|
result = list(map(int, index_select[1:-1].split(',')))
|
||||||
|
for n in result:
|
||||||
|
selected_title = db_title[n]
|
||||||
|
if selected_title['type'] == "movie":
|
||||||
|
console.print(f"[green]\nMovie select: {selected_title['name']}")
|
||||||
|
download_film(selected_title['id'], selected_title['slug'], domain)
|
||||||
|
else:
|
||||||
|
console.print(f"[green]\nTv select: {selected_title['name']}")
|
||||||
|
download_tv(selected_title['id'], selected_title['slug'], site_version, domain)
|
||||||
else:
|
else:
|
||||||
console.print("[red]Wrong index for selection")
|
console.print("[red]Wrong index for selection")
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user