This commit is contained in:
xyj 2023-12-02 20:00:27 +08:00
parent d4b6033aea
commit b34fe97f78
1 changed files with 20 additions and 3 deletions

23
tool.py
View File

@ -22,13 +22,30 @@ def update():
subprocess.Popen(['/bin/bash update.sh'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) subprocess.Popen(['/bin/bash update.sh'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
def get_list_record(msg, client):
import os
files = []
for filename in os.listdir('mp4'):
# 检查文件名是否符合格式 %Y-%m-%d_%H-%M-%S
if filename.startswith('2') and '-' in filename and '_' in filename:
# 提取日期和时间
date_str = filename.split('_')[0] # 例如 '2023-06-23'
time_str = filename.split('_')[1] # 例如 '06'
# 将日期和时间字符串转换为 datetime 对象
file_time = datetime.datetime(int(date_str[:4]), int(date_str[5:7]),
int(date_str[8:10]), int(time_str[:2]),
int(time_str[3:5]))
files.append(file_time)
def get_record(msg, client): def get_record(msg, client):
import requests import requests
create_time = json.loads(msg.payload.decode('utf-8'))["data"] create_time = json.loads(msg.payload.decode('utf-8'))["data"]
# create_time = '2023-12-01 19-07-58' # create_time = '2023-12-01_19-07-58'
import os import os
create_time_date_str = create_time.split(' ')[0] create_time_date_str = create_time.split('_')[0]
create_time_time_str = create_time.split(' ')[1] create_time_time_str = create_time.split('_')[1]
create_time_ = datetime.datetime(int(create_time_date_str[:4]), int(create_time_date_str[5:7]), create_time_ = datetime.datetime(int(create_time_date_str[:4]), int(create_time_date_str[5:7]),
int(create_time_date_str[8:10]), int(create_time_time_str[:2]), int(create_time_date_str[8:10]), int(create_time_time_str[:2]),
int(create_time_time_str[3:5])) int(create_time_time_str[3:5]))