-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
57 lines (49 loc) · 1.49 KB
/
Copy pathsetup.py
File metadata and controls
57 lines (49 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import yaml
import subprocess
import sys
import importlib.util
from plugin import *
REQUIRED_PACKAGES = [
("cloudscraper", "cloudscraper"),
("beautifulsoup4", "bs4"),
("lxml", "lxml"),
]
def _ensure_requirements():
missing = [package for package, module_name in REQUIRED_PACKAGES if importlib.util.find_spec(module_name) is None]
if not missing:
return
try:
subprocess.check_call([sys.executable, "-m", "pip", "install", *missing])
except Exception as e:
print(f"Failed to install requirements: {e}")
def _get_runtime_package_name():
return os.path.basename(os.path.dirname(__file__))
runtime_package_name = _get_runtime_package_name()
_ensure_requirements()
setting = {
"filepath": __file__,
"use_db": True,
"use_default_setting": True,
"home_module": "main",
"menu": {
"uri": runtime_package_name,
"name": "4KHD",
"list": [
{"uri": "main", "name": "최신"},
{"uri": "popular", "name": "인기"},
{"uri": "cosplay", "name": "코스플레이"},
{"uri": "album", "name": "앨범"},
{"uri": "search", "name": "검색"},
{"uri": "setting", "name": "설정"},
{"uri": "log", "name": "로그"},
],
},
"default_route": "single",
}
P = create_plugin_instance(setting)
try:
from .mod_main import ModuleMain
P.set_module_list([ModuleMain])
except Exception as e:
P.logger.error(f"Exception:{str(e)}")