]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/aliexpress.py
[ie/orf:on] Improve extraction (#9677)
[yt-dlp.git] / yt_dlp / extractor / aliexpress.py
CommitLineData
50311554 1from .common import InfoExtractor
50311554 2from ..compat import compat_str
23b2df82
S
3from ..utils import (
4 float_or_none,
5 try_get,
6)
50311554 7
8
9class AliExpressLiveIE(InfoExtractor):
23b2df82 10 _VALID_URL = r'https?://live\.aliexpress\.com/live/(?P<id>\d+)'
50311554 11 _TEST = {
12 'url': 'https://live.aliexpress.com/live/2800002704436634',
23b2df82 13 'md5': 'e729e25d47c5e557f2630eaf99b740a5',
50311554 14 'info_dict': {
15 'id': '2800002704436634',
23b2df82 16 'ext': 'mp4',
50311554 17 'title': 'CASIMA7.22',
50e93e03 18 'thumbnail': r're:https?://.*\.jpg',
50311554 19 'uploader': 'CASIMA Official Store',
23b2df82
S
20 'timestamp': 1500717600,
21 'upload_date': '20170722',
50311554 22 },
23 }
24
25 def _real_extract(self, url):
26 video_id = self._match_id(url)
23b2df82
S
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')
50311554 41
42 return {
43 'id': video_id,
23b2df82
S
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,
50311554 50 }