change model name
This commit is contained in:
+17
-5
@@ -81,6 +81,16 @@ class LogicQueue(object):
|
||||
monitor_thread = None
|
||||
current_ffmpeg_count = 0
|
||||
|
||||
@staticmethod
|
||||
def _get_setting(key, default=None):
|
||||
try:
|
||||
value = ModelSetting.get(key)
|
||||
if value in [None, ""]:
|
||||
return default
|
||||
return value
|
||||
except Exception:
|
||||
return default
|
||||
|
||||
@staticmethod
|
||||
def queue_start():
|
||||
try:
|
||||
@@ -104,16 +114,17 @@ class LogicQueue(object):
|
||||
|
||||
@staticmethod
|
||||
def _make_save_path(info):
|
||||
save_path = ModelSetting.get("download_path")
|
||||
if ModelSetting.get("auto_make_folder") == "True":
|
||||
save_path = LogicQueue._get_setting("download_path", os.path.join(F.config["path_data"], "linkkf"))
|
||||
if LogicQueue._get_setting("auto_make_folder", "True") == "True":
|
||||
save_path = os.path.join(save_path, info["save_folder"])
|
||||
if ModelSetting.get("linkkf_auto_make_season_folder") == "True":
|
||||
if LogicQueue._get_setting("linkkf_auto_make_season_folder", "True") == "True":
|
||||
save_path = os.path.join(save_path, f"Season {int(info['season'])}")
|
||||
return save_path
|
||||
|
||||
@staticmethod
|
||||
def _make_headers(video_info):
|
||||
referer = video_info[1] or f"{ModelSetting.get('linkkf_url').rstrip('/')}/"
|
||||
linkkf_url = str(LogicQueue._get_setting("linkkf_url", "https://linkkf.tv")).rstrip("/")
|
||||
referer = video_info[1] or f"{linkkf_url}/"
|
||||
return {
|
||||
"user-agent": (
|
||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) "
|
||||
@@ -376,7 +387,8 @@ class LogicQueue(object):
|
||||
while True:
|
||||
entity = None
|
||||
try:
|
||||
while LogicQueue.current_ffmpeg_count >= int(ModelSetting.get("max_ffmpeg_process_count")):
|
||||
max_count = int(LogicQueue._get_setting("max_ffmpeg_process_count", "4"))
|
||||
while LogicQueue.current_ffmpeg_count >= max_count:
|
||||
time.sleep(1)
|
||||
|
||||
entity = LogicQueue.download_queue.get()
|
||||
|
||||
@@ -16,6 +16,10 @@ REQUIRED_PACKAGES = [
|
||||
]
|
||||
|
||||
|
||||
def _get_runtime_package_name():
|
||||
return (__package__ or "").split(".")[0] or os.path.basename(os.path.dirname(__file__))
|
||||
|
||||
|
||||
def _get_declared_package_name():
|
||||
info_path = os.path.join(os.path.dirname(__file__), "info.yaml")
|
||||
try:
|
||||
@@ -43,6 +47,17 @@ def ensure_sqlalchemy_bind(package_name=None):
|
||||
return package_name
|
||||
|
||||
|
||||
def ensure_sqlalchemy_binds():
|
||||
names = []
|
||||
for candidate in [_get_declared_package_name(), _get_runtime_package_name()]:
|
||||
candidate = str(candidate or "").strip()
|
||||
if candidate != "" and candidate not in names:
|
||||
names.append(candidate)
|
||||
for name in names:
|
||||
ensure_sqlalchemy_bind(name)
|
||||
return names
|
||||
|
||||
|
||||
def _ensure_requirements():
|
||||
missing = [package for package, module_name in REQUIRED_PACKAGES if importlib.util.find_spec(module_name) is None]
|
||||
if not missing:
|
||||
@@ -75,9 +90,9 @@ setting = {
|
||||
"default_route": "single",
|
||||
}
|
||||
|
||||
|
||||
ensure_sqlalchemy_bind()
|
||||
ensure_sqlalchemy_binds()
|
||||
P = create_plugin_instance(setting)
|
||||
ensure_sqlalchemy_binds()
|
||||
ensure_sqlalchemy_bind(P.package_name)
|
||||
_ensure_requirements()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user