|
5 | 5 | from ykdl.videoinfo import VideoInfo
|
6 | 6 | from ykdl.util.html import get_content, add_header
|
7 | 7 | from ykdl.util.match import match1
|
8 |
| -from ykdl.compact import urlencode |
| 8 | +from ykdl.compact import urlencode, parse_qs |
9 | 9 |
|
10 | 10 | from .util import get_random_str, get_macid, cmd5x_iqiyi3 as cmd5x
|
11 | 11 |
|
@@ -72,14 +72,20 @@ def prepare(self):
|
72 | 72 | stream_id = self.type_2_id[stream_type]
|
73 | 73 |
|
74 | 74 | if stream['formatType'] == 'HLFLV':
|
| 75 | + stream_params = stream['url'].split('?')[-1] |
| 76 | + stream_params_dict = dict((k, v[0]) for k, v in parse_qs(stream_params).items()) |
| 77 | + if stream_params_dict['hl_sttp'] != 'flv': |
| 78 | + continue |
75 | 79 | params = {
|
76 | 80 | 'streamName': stream['streamName'],
|
77 |
| - 'streamParams': stream['url'].split('?')[-1], |
78 |
| - 'hl_stid': match1(stream['url'], 'hl_stid=(.+?)&') |
| 81 | + 'streamParams': stream_params, |
| 82 | + 'hl_stid': stream_params_dict['hl_stid'], |
| 83 | + 'hl_stft': stream_params_dict['hl_stft'], |
| 84 | + 'hl_stapp': stream_params_dict['hl_stapp'] |
79 | 85 | }
|
80 |
| - url = 'https://flvlive.video.iqiyi.com/liveugc/{streamName}.flv?{streamParams}'.format(**params) |
| 86 | + url = 'https://flvlive.video.iqiyi.com/{hl_stapp}/{streamName}.{hl_stft}?{streamParams}'.format(**params) |
81 | 87 | url = json.loads(get_content(url))['l']
|
82 |
| - url = url.replace('{streamName}.flv?'.format(**params), '{hl_stid}.flv?'.format(**params)) |
| 88 | + url = url.replace('{streamName}.'.format(**params), '{hl_stid}.'.format(**params)) |
83 | 89 | ext = 'flv'
|
84 | 90 | elif stream_id in info.streams:
|
85 | 91 | continue
|
|
0 commit comments