]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..compat import compat_str | |
3 | from ..utils import ( | |
4 | float_or_none, | |
5 | try_get, | |
6 | ) | |
7 | ||
8 | ||
9 | class AliExpressLiveIE(InfoExtractor): | |
10 | _VALID_URL = r'https?://live\.aliexpress\.com/live/(?P<id>\d+)' | |
11 | _TEST = { | |
12 | 'url': 'https://live.aliexpress.com/live/2800002704436634', | |
13 | 'md5': 'e729e25d47c5e557f2630eaf99b740a5', | |
14 | 'info_dict': { | |
15 | 'id': '2800002704436634', | |
16 | 'ext': 'mp4', | |
17 | 'title': 'CASIMA7.22', | |
18 | 'thumbnail': r're:https?://.*\.jpg', | |
19 | 'uploader': 'CASIMA Official Store', | |
20 | 'timestamp': 1500717600, | |
21 | 'upload_date': '20170722', | |
22 | }, | |
23 | } | |
24 | ||
25 | def _real_extract(self, url): | |
26 | video_id = self._match_id(url) | |
27 | ||
28 | webpage = self._download_webpage(url, video_id) | |
29 | ||
30 | data = self._parse_json( | |
31 | self._search_regex( | |
32 | r'(?s)runParams\s*=\s*({.+?})\s*;?\s*var', | |
33 | webpage, 'runParams'), | |
34 | video_id) | |
35 | ||
36 | title = data['title'] | |
37 | ||
38 | formats = self._extract_m3u8_formats( | |
39 | data['replyStreamUrl'], video_id, 'mp4', | |
40 | entry_protocol='m3u8_native', m3u8_id='hls') | |
41 | ||
42 | return { | |
43 | 'id': video_id, | |
44 | 'title': title, | |
45 | 'thumbnail': data.get('coverUrl'), | |
46 | 'uploader': try_get( | |
47 | data, lambda x: x['followBar']['name'], compat_str), | |
48 | 'timestamp': float_or_none(data.get('startTimeLong'), scale=1000), | |
49 | 'formats': formats, | |
50 | } |