Browse Source

ts:eventTime s

chenjunkai 6 năm trước cách đây
mục cha
commit
6922c556c6
2 tập tin đã thay đổi với 26 bổ sung12 xóa
  1. 1 0
      Ansjer/test/thumnber.py
  2. 25 12
      Controller/DetectController.py

+ 1 - 0
Ansjer/test/thumnber.py

@@ -11,6 +11,7 @@
 @file: xls.py
 @Contact: chanjunkai@163.com
 """
+
 import urllib
 import oss2
 

+ 25 - 12
Controller/DetectController.py

@@ -14,6 +14,7 @@
 import json
 import os
 import time
+import urllib
 
 import apns2
 import jpush as jpush
@@ -25,7 +26,7 @@ from django.views.generic.base import View
 from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET
 from Ansjer.config import BASE_DIR
 from Ansjer.config import SERVER_DOMAIN
-from Model.models import Device_Info, App_Info, UID_App
+from Model.models import Device_Info, VodHlsModel, UID_App
 from Model.models import Equipment_Info
 from Object.ResponseObject import ResponseObject
 from Object.TokenObject import TokenObject
@@ -91,21 +92,32 @@ class DetectControllerView(View):
         count = qs.count()
         qr = qs[(page - 1) * line:page * line]
         res = []
-        import oss2
         auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
         img_bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'apg')
+        # vod_time_list = []
         for p in qr:
+            devUid = p['devUid']
+            eventTime = p['eventTime']
             if p['is_st'] == 1:
-                p['img'] = img_bucket.sign_url('GET','{uid}/{channel}/{time}.jpeg'.
-                                           format(uid=p['devUid'], channel=p['Channel'], time=p['eventTime']), 300)
+                p['img'] = [img_bucket.sign_url('GET', '{uid}/{channel}/{time}.jpeg'.
+                                                format(uid=devUid, channel=p['Channel'], time=eventTime), 300)]
             elif p['is_st'] == 2:
-                # img_list = []
-
-                p['gif'] = []
-            uid_type_s = ''
-            if p['devUid'] in uid_type_dict.keys():
-                uid_type_s = uid_type_dict[p['devUid']]
-            p['uid_type'] = uid_type_s
+                # 列表装载回放时间戳标记
+                vodqs = VodHlsModel.objects.filter(uid=uid, channel=p['Channel'], time=eventTime) \
+                    .values("bucket__bucket", "bucket__endpoint")
+                bucket_name = vodqs[0]['bucket__bucket']
+                endpoint = vodqs[0]['bucket__endpoint']
+                bucket = oss2.Bucket(auth, endpoint, bucket_name)
+                ts = '{uid}/vod{channel}/{etime}/ts0.ts'.format(uid=devUid, channel=p['Channel'], etime=eventTime)
+                thumb0 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_0000,w_700'})
+                thumb1 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_1000,w_700'})
+                thumb2 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_2000,w_700'})
+                thumb3 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_3000,w_700'})
+                p['img'] = [thumb0, thumb1, thumb2, thumb3]
+            if devUid in uid_type_dict.keys():
+                p['uid_type'] = uid_type_dict[devUid]
+            else:
+                p['uid_type'] = ''
             res.append(p)
         return response.json(0, {'datas': res, 'count': count})
 
@@ -125,7 +137,8 @@ class DetectControllerView(View):
         if status == '0':
             if not all([app_type, appBundleId, uid, m_code]):
                 return response.json(444, 'app_type,appBundleId,uid,m_code')
-            uid_app_qs = UID_App.objects.filter(appBundleId=appBundleId, userID_id=userID, m_code=m_code,uid=uid, app_type=app_type)
+            uid_app_qs = UID_App.objects.filter(appBundleId=appBundleId, userID_id=userID, m_code=m_code, uid=uid,
+                                                app_type=app_type)
             if uid_app_qs.exists():
                 uid_app_qs.update(status=0)
                 return response.json(0)