From c08de1b1a98f5f9147a20acf659b97773a622ff4 Mon Sep 17 00:00:00 2001 From: Francesco Grazioso Date: Thu, 12 Jun 2025 16:58:14 +0200 Subject: [PATCH] Enhance command-line interface: add site specification and search terms support --- StreamingCommunity/run.py | 27 +++++++++++++++++++++++---- gui/tabs/run_tab.py | 6 +++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/StreamingCommunity/run.py b/StreamingCommunity/run.py index 82e4436..43e339d 100644 --- a/StreamingCommunity/run.py +++ b/StreamingCommunity/run.py @@ -241,6 +241,8 @@ def main(script_id = 0): ) parser.add_argument("script_id", nargs="?", default="unknown", help="ID dello script") + parser.add_argument('-s', '--search', default=None, help='Search terms') + parser.add_argument('--site', type=str, help='Specify site to search (e.g., streamingcommunity, eurostreaming)') # Add arguments for the main configuration parameters parser.add_argument( @@ -271,13 +273,11 @@ def main(script_id = 0): '--global', action='store_true', help='Perform a global search across multiple sites.' ) - # Add arguments for search functions - parser.add_argument('-s', '--search', default=None, help='Search terms') - # Parse command-line arguments args = parser.parse_args() - search_terms = args.search + specified_site = args.site + # Map command-line arguments to the config values config_updates = {} @@ -306,6 +306,25 @@ def main(script_id = 0): global_search(search_terms) return + # Modify the site selection logic: + if specified_site: + # Look for the specified site in the loaded functions + site_found = False + for alias, (func, use_for) in search_functions.items(): + module_name = alias.split("_")[0] + if module_name.lower() == specified_site.lower(): + run_function(func, search_terms=search_terms) + site_found = True + break + + if not site_found: + console.print(f"[red]Error: Site '{specified_site}' not found or not supported.") + if NOT_CLOSE_CONSOLE: + restart_script() + else: + force_exit() + return + # Create mappings using module indice input_to_function = {} choice_labels = {} diff --git a/gui/tabs/run_tab.py b/gui/tabs/run_tab.py index e855b7d..3c245dd 100644 --- a/gui/tabs/run_tab.py +++ b/gui/tabs/run_tab.py @@ -139,9 +139,9 @@ class RunTab(QTabWidget): site_index = self.site_combo.currentIndex() if site_index >= 0: - site_text = sites[site_index]["flag"] - site_name = site_text.split()[0].upper() - args.append(f"-{site_name}") + # Usa il nome completo del sito invece della flag abbreviata + site_name = sites[site_index]["name"].lower() + args.extend(["--site", site_name]) self.output_text.clear() print(f"Avvio script con argomenti: {' '.join(args)}")