You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.5 KiB

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