|
@@ -296,11 +296,12 @@ class CloudStorageView(View):
|
|
|
now_time = int(time.time())
|
|
|
|
|
|
split_vod_hls_obj = SplitVodHlsObject()
|
|
|
- vod_hls_qs = split_vod_hls_obj.get_vod_hls_data(uid=uid, channel=channel, start_time=start_time,
|
|
|
- end_time__gte=now_time).values("sec", "fg", "bucket_id")
|
|
|
+ vod_hls_qs = split_vod_hls_obj.get_vod_hls_data(uid=uid, channel=channel, start_time__gte=start_time,
|
|
|
+ end_time__gte=now_time).values("sec", "fg", "bucket_id",
|
|
|
+ 'start_time')[:10]
|
|
|
if not vod_hls_qs.exists():
|
|
|
return response.json(173)
|
|
|
- fg = int(vod_hls_qs[0]['fg'])
|
|
|
+ vod_hls_qs = sorted(vod_hls_qs, key=lambda item: item['start_time'])[:10]
|
|
|
bucket_id = vod_hls_qs[0]['bucket_id']
|
|
|
vod_bucket_qs = VodBucketModel.objects.filter(id=bucket_id).values('bucket', 'region', 'mold')
|
|
|
if not vod_bucket_qs.exists():
|
|
@@ -317,16 +318,20 @@ class CloudStorageView(View):
|
|
|
playlist_entries = []
|
|
|
# ts_count = fg & 0xf
|
|
|
# fg 64位整型,低四位代表ts文件总数,然后进行位运算,一次移四位,每四位转为十进制即为当前ts文件的秒数
|
|
|
- for i in range(15):
|
|
|
- shift = (i + 1) * 4
|
|
|
- duration = (fg >> shift) & 0xf
|
|
|
- if duration > 0:
|
|
|
- ts_file = '{uid}/vod{channel}/{time}/ts{i}.ts'.format(uid=uid, channel=channel, time=start_time, i=i)
|
|
|
- response_url = s3_obj.generate_file_obj_url(bucket_name, ts_file)
|
|
|
- playlist_entries.append({
|
|
|
- 'name': response_url,
|
|
|
- 'duration': duration,
|
|
|
- })
|
|
|
+ for item in vod_hls_qs:
|
|
|
+ fg = int(item['fg'])
|
|
|
+ temp_time = item['start_time']
|
|
|
+ for i in range(15):
|
|
|
+ shift = (i + 1) * 4
|
|
|
+ duration = (fg >> shift) & 0xf
|
|
|
+ if duration > 0:
|
|
|
+ ts_file = '{uid}/vod{channel}/{time}/ts{i}.ts'.format(uid=uid, channel=channel, time=temp_time,
|
|
|
+ i=i)
|
|
|
+ response_url = s3_obj.generate_file_obj_url(bucket_name, ts_file)
|
|
|
+ playlist_entries.append({
|
|
|
+ 'name': response_url,
|
|
|
+ 'duration': duration,
|
|
|
+ })
|
|
|
|
|
|
playlist = PlaylistGenerator(playlist_entries).generate()
|
|
|
response = HttpResponse(playlist)
|
|
@@ -397,7 +402,7 @@ class CloudStorageView(View):
|
|
|
"Effect": "Allow",
|
|
|
"Action": "s3:*",
|
|
|
"Resource": ["{aws_arn}:::{bucket_name}/{uid_channel}*".
|
|
|
- format(aws_arn=aws_arn, bucket_name=bucket_name, uid_channel=storage)]
|
|
|
+ format(aws_arn=aws_arn, bucket_name=bucket_name, uid_channel=storage)]
|
|
|
}
|
|
|
]
|
|
|
}
|
|
@@ -472,8 +477,8 @@ class CloudStorageView(View):
|
|
|
"dvQsModelOverTime": device_info_qs_time_over,
|
|
|
})
|
|
|
|
|
|
- if device_info_qs[0]['vodPrimaryUserID'] != user_id:
|
|
|
- return response.json(10034)
|
|
|
+ # if device_info_qs[0]['vodPrimaryUserID'] != user_id:
|
|
|
+ # return response.json(10034)
|
|
|
now_time = int(time.time())
|
|
|
uid_bucket_qs = UID_Bucket.objects.filter(uid=uid, endTime__gte=now_time, channel=channel).values(
|
|
|
'bucket_id').order_by('addTime')
|