diff --git a/StreamingCommunity/Lib/TMBD/tmdb.py b/StreamingCommunity/Lib/TMBD/tmdb.py index dce08134..5639268f 100644 --- a/StreamingCommunity/Lib/TMBD/tmdb.py +++ b/StreamingCommunity/Lib/TMBD/tmdb.py @@ -25,8 +25,6 @@ if not api_key and show_trending: show_trending = False - print("TMDB_API_KEY non trovata nel file .env") - #raise ValueError("TMDB_API_KEY non trovata nel file .env") def get_select_title(table_show_manager, generic_obj): @@ -307,6 +305,5 @@ def get_episodes(self, tv_show_id: int, season_number: int): return data[choice] - # Output -tmdb = TheMovieDB(api_key) \ No newline at end of file +tmdb = TheMovieDB(api_key) diff --git a/StreamingCommunity/Upload/version.py b/StreamingCommunity/Upload/version.py index 61189b60..5628a9f6 100644 --- a/StreamingCommunity/Upload/version.py +++ b/StreamingCommunity/Upload/version.py @@ -1,5 +1,5 @@ __title__ = 'StreamingCommunity' -__version__ = '3.4.4' +__version__ = '3.4.4.5' __author__ = 'Arrowar' __description__ = 'A command-line program to download film' __copyright__ = 'Copyright 2025' diff --git a/StreamingCommunity/run.py b/StreamingCommunity/run.py index 94b1dd64..df1643cc 100644 --- a/StreamingCommunity/run.py +++ b/StreamingCommunity/run.py @@ -278,6 +278,23 @@ def force_exit(): print("Uscita forzata con os._exit(0)") os._exit(0) +def check_env_file(): + required_keys = ['TMDB_API_KEY'] + + env_path = os.path.join(os.getcwd(), '.env') + if not os.path.isfile(env_path): + console.print("\n[red]Please create a .env file in the current directory with the necessary configurations.") + + for key in required_keys: + while True: + value = console.input(f"[cyan]Please enter the value for [bold]{key}[/bold]: [/cyan]").strip() + + with open(env_path, 'a') as f: + f.write(f"{key}={value}\n") + console.print(f"[green]{key} added to .env file.[/green]") + break + + console.print("\n[green].env file created successfully. Please restart the application.[/green]") def check_dns(): """Check DNS configuration and exit if required.""" @@ -472,6 +489,7 @@ def main(script_id=0): get_bot_instance().send_message(f"Avviato script {script_id}", None) Logger() + check_env_file() execute_hooks('pre_run') initialize() @@ -512,4 +530,4 @@ def main(script_id=0): if script_id != "unknown": TelegramSession.deleteScriptId(script_id) finally: - execute_hooks('post_run') \ No newline at end of file + execute_hooks('post_run')