Fix folder base stack,

This commit is contained in:
Lovi 2024-06-21 23:27:29 +02:00
parent 16b1e10cf6
commit 390319171f
3 changed files with 8 additions and 3 deletions

View File

@ -35,7 +35,7 @@ class VideoSource:
} }
self.is_series = False self.is_series = False
self.base_name = SITE_NAME self.base_name = SITE_NAME
self.domain = config_manager.get('SITE', self.base_name) self.domain = config_manager.get_dict('SITE', self.base_name)['domain']
def setup(self, media_id: int = None, series_name: str = None): def setup(self, media_id: int = None, series_name: str = None):
""" """

View File

@ -277,7 +277,9 @@ class M3U8_Segments:
# Get config site from prev stack # Get config site from prev stack
frames = get_call_stack() frames = get_call_stack()
config_site = str(os.path.basename(frames[-1]['folder'])).lower() logging.info(f"Extract info from: {frames}")
config_site = str(frames[-4]['folder_base'])
logging.info(f"Use frame: {frames[-1]}")
# Workers to use for downloading # Workers to use for downloading
TQDM_MAX_WORKER = 0 TQDM_MAX_WORKER = 0

View File

@ -15,6 +15,7 @@ def get_call_stack():
list: A list of dictionaries, each containing the following keys: list: A list of dictionaries, each containing the following keys:
- function (str): The name of the function. - function (str): The name of the function.
- folder (str): The directory path of the script containing the function. - folder (str): The directory path of the script containing the function.
- folder_base (str): The base name of the directory path.
- script (str): The name of the script file containing the function. - script (str): The name of the script file containing the function.
- line (int): The line number in the script where the function is defined. - line (int): The line number in the script where the function is defined.
@ -31,7 +32,7 @@ def get_call_stack():
>>> stack_trace = func_a() >>> stack_trace = func_a()
>>> for frame in stack_trace: >>> for frame in stack_trace:
... print(f"Function: {frame['function']}, Folder: {frame['folder']}, " ... print(f"Function: {frame['function']}, Folder: {frame['folder']}, "
... f"Script: {frame['script']}, Line: {frame['line']}") ... f"Folder Base: {frame['folder_base']}, Script: {frame['script']}, Line: {frame['line']}")
""" """
stack = inspect.stack() stack = inspect.stack()
call_stack = [] call_stack = []
@ -41,11 +42,13 @@ def get_call_stack():
filename = frame_info.filename filename = frame_info.filename
lineno = frame_info.lineno lineno = frame_info.lineno
folder_name = os.path.dirname(filename) folder_name = os.path.dirname(filename)
folder_base = os.path.basename(folder_name)
script_name = os.path.basename(filename) script_name = os.path.basename(filename)
call_stack.append({ call_stack.append({
"function": function_name, "function": function_name,
"folder": folder_name, "folder": folder_name,
"folder_base": folder_base,
"script": script_name, "script": script_name,
"line": lineno "line": lineno
}) })