From 4791de098dadbf4b86e94ef27a11a07f55a233ab Mon Sep 17 00:00:00 2001 From: Lovi <62809003+Lovi-0@users.noreply.github.com> Date: Mon, 17 Jun 2024 21:28:45 +0200 Subject: [PATCH] Add loiggin load module. --- Src/Api/altadefinizione/__init__.py | 1 + Src/Api/animeunity/__init__.py | 2 +- Src/Api/ddlstreamitaly/__init__.py | 1 + Src/Api/guardaserie/__init__.py | 1 + Src/Api/streamingcommunity/__init__.py | 1 + requirements.txt | 4 +++- run.py | 21 +++++++++++++++++---- 7 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Src/Api/altadefinizione/__init__.py b/Src/Api/altadefinizione/__init__.py index 27a9885..561a33b 100644 --- a/Src/Api/altadefinizione/__init__.py +++ b/Src/Api/altadefinizione/__init__.py @@ -11,6 +11,7 @@ from .film import download_film # Variable indice = 2 +_deprecate = False def search(): diff --git a/Src/Api/animeunity/__init__.py b/Src/Api/animeunity/__init__.py index b7fe3ed..a8de4b7 100644 --- a/Src/Api/animeunity/__init__.py +++ b/Src/Api/animeunity/__init__.py @@ -11,7 +11,7 @@ from .anime import donwload_film, donwload_series # Variable indice = 1 - +_deprecate = False def search(): diff --git a/Src/Api/ddlstreamitaly/__init__.py b/Src/Api/ddlstreamitaly/__init__.py index 411fa85..01eae2a 100644 --- a/Src/Api/ddlstreamitaly/__init__.py +++ b/Src/Api/ddlstreamitaly/__init__.py @@ -15,6 +15,7 @@ from .series import download_thread # Variable indice = 3 +_deprecate = False def search(): diff --git a/Src/Api/guardaserie/__init__.py b/Src/Api/guardaserie/__init__.py index e7e05c7..f360c76 100644 --- a/Src/Api/guardaserie/__init__.py +++ b/Src/Api/guardaserie/__init__.py @@ -11,6 +11,7 @@ from .series import download_series # Variable indice = 4 +_deprecate = False def search(): diff --git a/Src/Api/streamingcommunity/__init__.py b/Src/Api/streamingcommunity/__init__.py index 078449a..9994906 100644 --- a/Src/Api/streamingcommunity/__init__.py +++ b/Src/Api/streamingcommunity/__init__.py @@ -17,6 +17,7 @@ from .series import download_series # Variable indice = 0 +_deprecate = False def search(): diff --git a/requirements.txt b/requirements.txt index 0343d08..9782604 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,6 @@ -httpx +urllib3 +certifi +httpx bs4 rich tqdm diff --git a/run.py b/run.py index 1eec363..d238397 100644 --- a/run.py +++ b/run.py @@ -3,6 +3,7 @@ import os import sys import glob +import logging import platform import argparse import importlib @@ -47,20 +48,29 @@ def load_search_functions(): # Traverse the Api directory api_dir = os.path.join(os.path.dirname(__file__), 'Src', 'Api') init_files = glob.glob(os.path.join(api_dir, '*', '__init__.py')) + + logging.info(f"Base folder path: {api_dir}") + logging.info(f"Api module path: {init_files}") + # Retrieve modules and their indices for init_file in init_files: - module_name = os.path.basename(os.path.dirname(init_file)) # Get folder name as module name + + # Get folder name as module name + module_name = os.path.basename(os.path.dirname(init_file)) + logging.info(f"Load module name: {module_name}") try: # Dynamically import the module mod = importlib.import_module(f'Src.Api.{module_name}') # Get 'indice' from the module - indice = getattr(mod, 'indice', 0) # If 'indice' is not defined, default to 0 + indice = getattr(mod, 'indice', 0) + is_deprecate = bool(getattr(mod, '_deprecate', True)) # Add module and indice to the list - modules.append((module_name, indice)) + if not is_deprecate: + modules.append((module_name, indice)) except Exception as e: console.print(f"[red]Failed to import module {module_name}: {str(e)}") @@ -70,7 +80,10 @@ def load_search_functions(): # Load search functions in the sorted order for module_name, _ in modules: - module_alias = f'{module_name}_search' # Construct a unique alias for the module + + # Construct a unique alias for the module + module_alias = f'{module_name}_search' + logging.info(f"Module alias: {module_alias}") try: # Dynamically import the module