diff --git a/main.py b/main.py index eed0a0be288..e9656353303 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,4 @@ import asyncio -from utils.config import resource_path import utils.constants as constants from utils.channel import ( get_channel_items, @@ -20,6 +19,7 @@ process_nested_dict, format_interval, check_ipv6_support, + resource_path, ) from updates.subscribe import get_channels_by_subscribe_urls from updates.multicast import get_channels_by_multicast diff --git a/tkinter_ui/about.py b/tkinter_ui/about.py index 0bbc75e10b6..d2e2a204240 100644 --- a/tkinter_ui/about.py +++ b/tkinter_ui/about.py @@ -1,7 +1,7 @@ import tkinter as tk from PIL import Image, ImageTk import webbrowser -from utils.config import resource_path +from utils.tools import resource_path class AboutUI: diff --git a/updates/fofa/request.py b/updates/fofa/request.py index 579acceec17..e35f575dae9 100644 --- a/updates/fofa/request.py +++ b/updates/fofa/request.py @@ -1,4 +1,3 @@ -from utils.config import resource_path import utils.constants as constants from tqdm.asyncio import tqdm_asyncio from time import time @@ -9,7 +8,7 @@ import re from utils.retry import retry_func from utils.channel import format_channel_name -from utils.tools import merge_objects, get_pbar_remaining, add_url_info +from utils.tools import merge_objects, get_pbar_remaining, add_url_info, resource_path from updates.proxy import get_proxy, get_proxy_next from requests_custom.utils import get_source_requests, close_session from collections import defaultdict diff --git a/updates/multicast/update_tmp.py b/updates/multicast/update_tmp.py index 628e9c4bbc9..eeeb06ad537 100644 --- a/updates/multicast/update_tmp.py +++ b/updates/multicast/update_tmp.py @@ -5,10 +5,9 @@ from updates.subscribe import get_channels_by_subscribe_urls from driver.utils import get_soup_driver -from utils.config import resource_path import utils.constants as constants from utils.channel import format_channel_name, get_name_url -from utils.tools import get_pbar_remaining +from utils.tools import get_pbar_remaining, resource_path import json # import asyncio diff --git a/utils/config.py b/utils/config.py index deaa38f67d9..1e62304c8d9 100644 --- a/utils/config.py +++ b/utils/config.py @@ -1,23 +1,7 @@ import os -import sys import configparser import shutil - - -def resource_path(relative_path, persistent=False): - """ - Get the resource path - """ - base_path = os.path.abspath(".") - total_path = os.path.join(base_path, relative_path) - if persistent or os.path.exists(total_path): - return total_path - else: - try: - base_path = sys._MEIPASS - return os.path.join(base_path, relative_path) - except Exception: - return total_path +from utils.tools import resource_path def get_config(): diff --git a/utils/tools.py b/utils/tools.py index f55d1ea0901..e23717a4d6c 100644 --- a/utils/tools.py +++ b/utils/tools.py @@ -5,7 +5,6 @@ import ipaddress from urllib.parse import urlparse import socket -from utils.config import resource_path from utils.constants import get_resolution_value import utils.constants as constants import re @@ -13,6 +12,7 @@ from flask import render_template_string, send_file import shutil import requests +import sys def format_interval(t): @@ -458,3 +458,19 @@ def remove_cache_info(str): Remove the cache info from the string """ return re.sub(r"cache:.*|\|cache:.*", "", str) + + +def resource_path(relative_path, persistent=False): + """ + Get the resource path + """ + base_path = os.path.abspath(".") + total_path = os.path.join(base_path, relative_path) + if persistent or os.path.exists(total_path): + return total_path + else: + try: + base_path = sys._MEIPASS + return os.path.join(base_path, relative_path) + except Exception: + return total_path