mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-05 02:55:25 +00:00
Site: Fix color map
This commit is contained in:
parent
a071d0d2c4
commit
e75d8185f9
@ -21,9 +21,9 @@ from .title import download_title
|
|||||||
|
|
||||||
# Variable
|
# Variable
|
||||||
indice = 3
|
indice = 3
|
||||||
_useFor = "film_serie"
|
_useFor = "Torrent"
|
||||||
_priority = 0
|
_priority = 0
|
||||||
_engineDownload = "tor"
|
_engineDownload = "Torrent"
|
||||||
_deprecate = False
|
_deprecate = False
|
||||||
|
|
||||||
console = Console()
|
console = Console()
|
||||||
|
@ -24,7 +24,7 @@ from .series import download_series
|
|||||||
|
|
||||||
# Variable
|
# Variable
|
||||||
indice = 2
|
indice = 2
|
||||||
_useFor = "film_serie"
|
_useFor = "Film_&_Serie"
|
||||||
_priority = 0
|
_priority = 0
|
||||||
_engineDownload = "hls"
|
_engineDownload = "hls"
|
||||||
_deprecate = True
|
_deprecate = True
|
||||||
|
@ -24,7 +24,7 @@ from .serie import download_series
|
|||||||
|
|
||||||
# Variable
|
# Variable
|
||||||
indice = 1
|
indice = 1
|
||||||
_useFor = "anime"
|
_useFor = "Anime"
|
||||||
_priority = 0
|
_priority = 0
|
||||||
_engineDownload = "mp4"
|
_engineDownload = "mp4"
|
||||||
_deprecate = False
|
_deprecate = False
|
||||||
|
@ -18,8 +18,8 @@ from .film import download_film
|
|||||||
|
|
||||||
|
|
||||||
# Variable
|
# Variable
|
||||||
indice = 8
|
indice = 6
|
||||||
_useFor = "anime"
|
_useFor = "Anime"
|
||||||
_priority = 0
|
_priority = 0
|
||||||
_engineDownload = "mp4"
|
_engineDownload = "mp4"
|
||||||
_deprecate = False
|
_deprecate = False
|
||||||
|
@ -20,8 +20,8 @@ from .series import download_series
|
|||||||
|
|
||||||
|
|
||||||
# Variable
|
# Variable
|
||||||
indice = 5
|
indice = 4
|
||||||
_useFor = "serie"
|
_useFor = "Serie"
|
||||||
_priority = 0
|
_priority = 0
|
||||||
_engineDownload = "hls"
|
_engineDownload = "hls"
|
||||||
_deprecate = False
|
_deprecate = False
|
||||||
|
@ -19,8 +19,8 @@ from .film import download_film
|
|||||||
|
|
||||||
|
|
||||||
# Variable
|
# Variable
|
||||||
indice = 8
|
indice = 5
|
||||||
_useFor = "film_serie"
|
_useFor = "Film_&_Serie"
|
||||||
_priority = 1 # NOTE: Site search need the use of tmbd obj
|
_priority = 1 # NOTE: Site search need the use of tmbd obj
|
||||||
_engineDownload = "hls"
|
_engineDownload = "hls"
|
||||||
_deprecate = False
|
_deprecate = False
|
||||||
|
@ -25,7 +25,7 @@ from .series import download_series
|
|||||||
|
|
||||||
# Variable
|
# Variable
|
||||||
indice = 0
|
indice = 0
|
||||||
_useFor = "film_serie"
|
_useFor = "Film_&_Serie"
|
||||||
_priority = 0
|
_priority = 0
|
||||||
_engineDownload = "hls"
|
_engineDownload = "hls"
|
||||||
_deprecate = False
|
_deprecate = False
|
||||||
|
@ -19,8 +19,8 @@ from .series import download_series
|
|||||||
|
|
||||||
|
|
||||||
# Variable
|
# Variable
|
||||||
indice = 8
|
indice = 7
|
||||||
_useFor = "film_serie"
|
_useFor = "Film_&_Serie"
|
||||||
_priority = 10 # !!! MOLTO LENTO
|
_priority = 10 # !!! MOLTO LENTO
|
||||||
_engineDownload = "hls"
|
_engineDownload = "hls"
|
||||||
_deprecate = False
|
_deprecate = False
|
||||||
|
@ -193,6 +193,13 @@ def force_exit():
|
|||||||
|
|
||||||
def main(script_id = 0):
|
def main(script_id = 0):
|
||||||
|
|
||||||
|
color_map = {
|
||||||
|
"anime": "red",
|
||||||
|
"film_&_serie": "yellow",
|
||||||
|
"serie": "blue",
|
||||||
|
"torrent": "white"
|
||||||
|
}
|
||||||
|
|
||||||
if TELEGRAM_BOT:
|
if TELEGRAM_BOT:
|
||||||
bot = get_bot_instance()
|
bot = get_bot_instance()
|
||||||
bot.send_message(f"Avviato script {script_id}", None)
|
bot.send_message(f"Avviato script {script_id}", None)
|
||||||
@ -256,18 +263,6 @@ def main(script_id = 0):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Add arguments for search functions
|
# Add arguments for search functions
|
||||||
color_map = {
|
|
||||||
"anime": "red",
|
|
||||||
"film_serie": "yellow",
|
|
||||||
"film": "blue",
|
|
||||||
"serie": "green",
|
|
||||||
"other": "white"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Add numeric arguments for each search module
|
|
||||||
for idx, (alias, (_, use_for)) in enumerate(search_functions.items()):
|
|
||||||
parser.add_argument(f'--{idx}', action='store_true', help=f'Search using {alias.split("_")[0]} ({use_for})')
|
|
||||||
|
|
||||||
parser.add_argument('-s', '--search', default=None, help='Search terms')
|
parser.add_argument('-s', '--search', default=None, help='Search terms')
|
||||||
|
|
||||||
# Parse command-line arguments
|
# Parse command-line arguments
|
||||||
@ -302,44 +297,41 @@ def main(script_id = 0):
|
|||||||
global_search(search_terms)
|
global_search(search_terms)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Check for numeric arguments
|
# Create mappings using module indice
|
||||||
search_functions_list = list(search_functions.items())
|
input_to_function = {}
|
||||||
for i in range(len(search_functions_list)):
|
choice_labels = {}
|
||||||
if getattr(args, str(i)):
|
|
||||||
alias, (func, _) = search_functions_list[i]
|
for alias, (func, use_for) in search_functions.items():
|
||||||
run_function(func, search_terms=search_terms)
|
module_name = alias.split("_")[0]
|
||||||
return
|
try:
|
||||||
|
mod = importlib.import_module(f'StreamingCommunity.Api.Site.{module_name}')
|
||||||
|
site_index = str(getattr(mod, 'indice'))
|
||||||
|
input_to_function[site_index] = func
|
||||||
|
choice_labels[site_index] = (module_name.capitalize(), use_for.lower())
|
||||||
|
except Exception as e:
|
||||||
|
console.print(f"[red]Error mapping module {module_name}: {str(e)}")
|
||||||
|
|
||||||
# Mapping user input to functions
|
# Display the category legend
|
||||||
input_to_function = {str(i): func for i, (alias, (func, _)) in enumerate(search_functions.items())}
|
|
||||||
|
|
||||||
# Create dynamic prompt message and choices
|
|
||||||
choice_labels = {str(i): (alias.split("_")[0].capitalize(), use_for) for i, (alias, (_, use_for)) in enumerate(search_functions.items())}
|
|
||||||
|
|
||||||
# Display the category legend in a single line
|
|
||||||
legend_text = " | ".join([f"[{color}]{category.capitalize()}[/{color}]" for category, color in color_map.items()])
|
legend_text = " | ".join([f"[{color}]{category.capitalize()}[/{color}]" for category, color in color_map.items()])
|
||||||
console.print(f"\n[bold green]Category Legend:[/bold green] {legend_text}")
|
console.print(f"\n[bold green]Category Legend:[/bold green] {legend_text}")
|
||||||
|
|
||||||
# Construct the prompt message with color-coded site names and aliases
|
# Construct prompt with proper color mapping
|
||||||
prompt_message = "[green]Insert category [white](" + ", ".join(
|
prompt_message = "[green]Insert category [white](" + ", ".join(
|
||||||
[f"{key}: [{color_map.get(label[1], 'white')}]{label[0]}"
|
[f"[{color_map.get(label[1], 'white')}]{key}: {label[0]}[/{color_map.get(label[1], 'white')}]"
|
||||||
for key, label in choice_labels.items()]
|
for key, label in choice_labels.items()]
|
||||||
) + "[white])"
|
) + "[white])"
|
||||||
|
|
||||||
if TELEGRAM_BOT:
|
if TELEGRAM_BOT:
|
||||||
# Display the category legend in a single line
|
|
||||||
category_legend_str = "Categorie: \n" + " | ".join([
|
category_legend_str = "Categorie: \n" + " | ".join([
|
||||||
f"{category.capitalize()}" for category in color_map.keys()
|
f"{category.capitalize()}" for category in color_map.keys()
|
||||||
])
|
])
|
||||||
|
|
||||||
# Build message with aliases
|
|
||||||
prompt_message = "Inserisci il sito:\n" + "\n".join(
|
prompt_message = "Inserisci il sito:\n" + "\n".join(
|
||||||
[f"{key}: {label[0]}" for key, label in choice_labels.items()]
|
[f"{key}: {label[0]}" for key, label in choice_labels.items()]
|
||||||
)
|
)
|
||||||
|
|
||||||
console.print(f"\n{prompt_message}")
|
console.print(f"\n{prompt_message}")
|
||||||
|
|
||||||
# Chiedi la scelta all'utente con il bot Telegram
|
|
||||||
category = bot.ask(
|
category = bot.ask(
|
||||||
"select_provider",
|
"select_provider",
|
||||||
f"{category_legend_str}\n\n{prompt_message}",
|
f"{category_legend_str}\n\n{prompt_message}",
|
||||||
@ -351,13 +343,6 @@ def main(script_id = 0):
|
|||||||
|
|
||||||
# Run the corresponding function based on user input
|
# Run the corresponding function based on user input
|
||||||
if category in input_to_function:
|
if category in input_to_function:
|
||||||
"""if category == global_search_key:
|
|
||||||
# Run global search
|
|
||||||
run_function(input_to_function[category], search_terms=search_terms)
|
|
||||||
|
|
||||||
else:"""
|
|
||||||
|
|
||||||
# Run normal site-specific search
|
|
||||||
run_function(input_to_function[category], search_terms=search_terms)
|
run_function(input_to_function[category], search_terms=search_terms)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user