]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/aliexpress.py
debian/control: Mark compliance with policy 4.1.1. No further changes needed.
[youtubedl] / youtube_dl / extractor / aliexpress.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..compat import compat_str
6 from ..utils import (
7 float_or_none,
8 try_get,
9 )
10
11
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',
25 },
26 }
27
28 def _real_extract(self, url):
29 video_id = self._match_id(url)
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')
44
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,
53 }