Add loiggin load module.

This commit is contained in:
Lovi 2024-06-17 21:28:45 +02:00
parent f41490fa33
commit 4791de098d
7 changed files with 25 additions and 6 deletions

View File

@ -11,6 +11,7 @@ from .film import download_film
# Variable
indice = 2
_deprecate = False
def search():

View File

@ -11,7 +11,7 @@ from .anime import donwload_film, donwload_series
# Variable
indice = 1
_deprecate = False
def search():

View File

@ -15,6 +15,7 @@ from .series import download_thread
# Variable
indice = 3
_deprecate = False
def search():

View File

@ -11,6 +11,7 @@ from .series import download_series
# Variable
indice = 4
_deprecate = False
def search():

View File

@ -17,6 +17,7 @@ from .series import download_series
# Variable
indice = 0
_deprecate = False
def search():

View File

@ -1,4 +1,6 @@
httpx
urllib3
certifi
httpx
bs4
rich
tqdm

19
run.py
View File

@ -3,6 +3,7 @@
import os
import sys
import glob
import logging
import platform
import argparse
import importlib
@ -48,18 +49,27 @@ def load_search_functions():
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
if not is_deprecate:
modules.append((module_name, indice))
except Exception as 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