-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathmain.py
42 lines (40 loc) · 1.58 KB
/
main.py
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
import os
import time
import shutil
from api.media import media
from system.log import log
from api.media_config import MediaConfig
from system.config import Config
if __name__ == "__main__":
try:
if not os.path.exists(os.path.join(os.getcwd(), "config", "config.yaml")):
log().logger.info(
"配置文件不存在, 拷贝默认配置文件[config.default.yaml]->[/config/config.yaml]"
)
shutil.copy("config.default.yaml", "config/config.yaml")
if not os.path.exists(
os.path.join(os.getcwd(), "config", "config.default.yaml")
):
log().logger.info(
"默认配置文件不存在, 拷贝默认配置文件[config.default.yaml]->[/config/config.default.yaml]"
)
shutil.copy("config.default.yaml", "config/config.default.yaml")
_ = MediaConfig()
config = Config().get_config()
mediaclient = media()
while True:
try:
log().logger.info("开始刷新媒体库元数据")
mediaclient.start_scan_media()
log().logger.info("刷新媒体库元数据完成")
time.sleep(config["system"]["updatetime"] * 3600)
except Exception as result:
log().logger.info(result)
except Exception as result:
log().logger.info(
"文件[{}]行[{}]异常错误:{}".format(
result.__traceback__.tb_frame.f_globals["__file__"],
result.__traceback__.tb_lineno,
result,
)
)