]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/aliexpress.py
Completely change project name to yt-dlp (#85)
[yt-dlp.git] / yt_dlp / extractor / aliexpress.py
CommitLineData
50311554 1# coding: utf-8
2from __future__ import unicode_literals
3
50311554 4from .common import InfoExtractor
50311554 5from ..compat import compat_str
23b2df82
S
6from ..utils import (
7 float_or_none,
8 try_get,
9)
50311554 10
11
12class AliExpressLiveIE(InfoExtractor):
23b2df82 13 _VALID_URL = r'https?://live\.aliexpress\.com/live/(?P<id>\d+)'
50311554 14 _TEST = {
15 'url': 'https://live.aliexpress.com/live/2800002704436634',
23b2df82 16 'md5': 'e729e25d47c5e557f2630eaf99b740a5',
50311554 17 'info_dict': {
18 'id': '2800002704436634',
23b2df82 19 'ext': 'mp4',
50311554 20 'title': 'CASIMA7.22',
23b2df82 21 'thumbnail': r're:http://.*\.jpg',
50311554 22 'uploader': 'CASIMA Official Store',
23b2df82
S
23 'timestamp': 1500717600,
24 'upload_date': '20170722',
50311554 25 },
26 }
27
28 def _real_extract(self, url):
29 video_id = self._match_id(url)
23b2df82
S
30
31 webpage = self._download_webpage(url, video_id)
32
33 data = self._parse_json(
34 self._search_regex(
35 r'(?s)runParams\s*=\s*({.+?})\s*;?\s*var',
36 webpage, 'runParams'),
37 video_id)
38
39 title = data['title']
40
41 formats = self._extract_m3u8_formats(
42 data['replyStreamUrl'], video_id, 'mp4',
43 entry_protocol='m3u8_native', m3u8_id='hls')
50311554 44
45 return {
46 'id': video_id,
23b2df82
S
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,
50311554 53 }