Initial clone based on d65d89183f645a0e95910c3861491a75c26000eb upstream which is...
[youtube-dl.git] / youtube_dl / extractor / aliexpress.py
blob6f241e683767f9e43e6e981af2e51564a0f9107f
1 # coding: utf-8
2 from __future__ import unicode_literals
4 from .common import InfoExtractor
5 from ..compat import compat_str
6 from ..utils import (
7 float_or_none,
8 try_get,
12 class AliExpressLiveIE(InfoExtractor):
13 _VALID_URL = r'https?://live\.aliexpress\.com/live/(?P<id>\d+)'
14 _TEST = {
15 'url': 'https://live.aliexpress.com/live/2800002704436634',
16 'md5': 'e729e25d47c5e557f2630eaf99b740a5',
17 'info_dict': {
18 'id': '2800002704436634',
19 'ext': 'mp4',
20 'title': 'CASIMA7.22',
21 'thumbnail': r're:http://.*\.jpg',
22 'uploader': 'CASIMA Official Store',
23 'timestamp': 1500717600,
24 'upload_date': '20170722',
28 def _real_extract(self, url):
29 video_id = self._match_id(url)
31 webpage = self._download_webpage(url, video_id)
33 data = self._parse_json(
34 self._search_regex(
35 r'(?s)runParams\s*=\s*({.+?})\s*;?\s*var',
36 webpage, 'runParams'),
37 video_id)
39 title = data['title']
41 formats = self._extract_m3u8_formats(
42 data['replyStreamUrl'], video_id, 'mp4',
43 entry_protocol='m3u8_native', m3u8_id='hls')
45 return {
46 'id': video_id,
47 'title': title,
48 'thumbnail': data.get('coverUrl'),
49 'uploader': try_get(
50 data, lambda x: x['followBar']['name'], compat_str),
51 'timestamp': float_or_none(data.get('startTimeLong'), scale=1000),
52 'formats': formats,