This commit is contained in:
2023-01-28 13:34:35 +08:00
parent 52c6ecda01
commit ffe2ad0e1c
2 changed files with 37 additions and 4 deletions

31
up_again.py Normal file
View File

@ -0,0 +1,31 @@
import os
import requests
from obs import ObsClient
obsClient = ObsClient(
access_key_id='LHXJC7GIC2NNUUHHTNVI',
secret_access_key='sVWvEItrFKWPp5DxeMvX8jLFU69iXPpzkjuMX3iM',
server='https://obs.cn-east-3.myhuaweicloud.com'
)
bucketName = 'ieemoo-ai'
def upAgain(path, url):
for name in os.listdir(path):
try:
file_path = os.sep.join([path, name])
videoUuid = name.split('_')[1]
json_date = {'videoUuid': videoUuid}
resp = requests.post(url=url,
data=json_date)
status = resp.json()['data']
time = name.split('-')[0]
objectkey = 'videos/'+time+'/'+status+'/'+status+'_'+name
#print('>>>>>>>>>',objectkey)
resp = obsClient.putFile(bucketName, objectkey, file_path)
os.remove(file_path)
except Exception as e:
print(e)
if __name__ == '__main__':
path = '../module/ieemoo-ai-searchv2/videos'
url = 'https://api.ieemoo.com/emoo-api/intelligence/queryVideoCompareResult.do'
upAgain(path, url)

View File

@ -27,7 +27,8 @@ def AddObs(file_path, status):
shutil.move(file_path, f_dst)
def addobs(file_path, status): #save videos
ti.sleep(3)
T1 = ti.time()
ti.sleep(1)
num = 0
videoUuid = os.path.basename(file_path).split('_')[1]
json_data = {'videoUuid': videoUuid}
@ -35,14 +36,16 @@ def addobs(file_path, status): #save videos
data=json_data)
status = resp.json()
if not 'data' in status:#延迟设置
while num < 20:
ti.sleep(2)
for _ in range(20):
ti.sleep(1)
num += 1
resp = requests.post(url=cfg.Vre, data=json_data)
status = resp.json()
if not 'data' in status:
continue
else:break
T2 = ti.time()
print('videoUuid>>>{} get_status_time>>>{}'.format((videoUuid), (T2-T1)))
status = status['data']
objectkey = os.path.basename(file_path)
@ -72,7 +75,6 @@ def updateAgain():
except Exception as e:
pass
def Addimg(uuid_barcode):
time = uuid_barcode.split('-')[0].split('_')[-1]
objectkey = 'imgs/'+time+'/'+uuid_barcode+'.jpg'