+ prefered_edge = cdn_data.get('preferedEdge')
+ formats = []
+
+ for edge in cdn_data['edges']:
+ edge_ep = edge.get('ep')
+ if not edge_ep or not isinstance(edge_ep, compat_str):
+ continue
+ edge_id = edge.get('id')
+ for tech in cdn_data['techs']:
+ tech_label = tech.get('label')
+ tech_type = tech.get('type')
+ preference = 0
+ if edge_id == prefered_edge:
+ preference += 1
+ format_id = []
+ if edge_id:
+ format_id.append(edge_id)
+ if tech_type == 'application/x-mpegurl' or tech_label == 'HLS':
+ format_id.append('hls')
+ formats.extend(self._extract_m3u8_formats(
+ update_url_query(
+ 'https://%s/hls/%s/index.m3u8'
+ % (edge_ep, channel_id), params),
+ channel_id, 'mp4', preference=preference,
+ m3u8_id='-'.join(format_id), fatal=False))
+ continue
+ elif tech_type == 'video/mp4' or tech_label == 'MP4':
+ format_id.append('mp4')
+ formats.append({
+ 'url': update_url_query(
+ 'https://%s/mp4/%s.mp4' % (edge_ep, channel_id),
+ params),
+ 'format_id': '-'.join(format_id),
+ 'preference': preference,
+ })
+ else:
+ # rtmp format does not seem to work
+ continue