mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 12:05:35 +00:00
Refactor user input handling in main function now you can choose more than one movie or tv
This commit is contained in:
parent
2c97ccb835
commit
7c17c1eba4
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