Browse Source

云盘播放列表

peng 2 years ago
parent
commit
94d09dcc3b
1 changed files with 9 additions and 8 deletions
  1. 9 8
      Controller/IcloudService/IcloudService.py

+ 9 - 8
Controller/IcloudService/IcloudService.py

@@ -413,7 +413,8 @@ class IcloudServiceView(View):
         if file_type:  # 按文件类型查询
             icloud_record_qs = icloud_record_qs.filter(file_type=file_type)
         icloud_record_qs = icloud_record_qs.values('bucket_id', 'sec', 'fg', 'nickname', 'uid', 'channel', 'size', 'id',
-                                                   'time_stamp').order_by('-time_stamp')[(page - 1) * line:page * line]
+                                                   'time_stamp', 'file_type').order_by('-time_stamp')[
+                           (page - 1) * line:page * line]
         if not icloud_record_qs.exists():
             return response.json(0, icloud_list)
         bucket_id = icloud_record_qs[0]['bucket_id']
@@ -434,15 +435,17 @@ class IcloudServiceView(View):
                 uid = item['uid']
                 channel = item['channel']
                 time_stamp = item['time_stamp']
+                file_type = item['file_type']
                 total_size += float(item['size'])
                 uid_token = TokenObject().encryption(data={'uid': uid})
                 res_data = {
-                    'is_show': 1 if total_size < all_size else 0,
+                    'is_show': 1 if total_size < all_size else 0,  # 只展示剩余容量的数据,超过的部分不展示
                     'time_stamp': time_stamp,
                     'icloud_id': item['id'],
+                    'file_type': file_type,
+                    'nick_name': item['nickname']
                 }
-                if file_type == '0':  # 图片
-                    res_data['file_type'] = 0
+                if file_type == 0:  # 图片,只返回图片地址
                     thumbs_png = '{user_id}/image_file/{uid}/channel{channel}/{time}/{time}.jpeg'.format(
                         user_id=user_id,
                         uid=uid,
@@ -451,8 +454,7 @@ class IcloudServiceView(View):
                     response_url = s3_obj.generate_file_obj_url(bucket_name, thumbs_png)
                     res_data['thumb'] = response_url
                     icloud_list.append(res_data)
-                elif file_type == '1':  # ts文件
-                    res_data['file_type'] = 1
+                elif file_type == 1:  # ts文件,返回播放地址
                     thumbs_png = '{user_id}/image_file/{uid}/channel{channel}/{time}/{time}.jpeg'.format(
                         user_id=user_id,
                         uid=uid,
@@ -468,8 +470,7 @@ class IcloudServiceView(View):
                     res_data['icloud_url'] = icloud_url
                     res_data['sec'] = item['sec']
                     icloud_list.append(res_data)
-                elif file_type == '2':  # mp4文件
-                    res_data['file_type'] = 2
+                elif file_type == 2:  # mp4文件,返回播放地址
                     icloud_url = '{server_domain}icloud/service/icloudPlayUrl?' \
                                  'uid={uid}&channel={channel}&time_stamp={time_stamp}&file_type=1&sign=tktktktk'. \
                         format(server_domain=SERVER_DOMAIN_SSL, uid=uid_token, channel=channel, time_stamp=time_stamp)