aliexpress.py 1.5 KB

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