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