twentythreevideo.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. class TwentyThreeVideoIE(InfoExtractor):
  4. IE_NAME = '23video'
  5. _VALID_URL = r'https?://(?:www\.)?(?P<client>[\w-]+)\.23video\.com/v.ihtml/player.html.*photo_id=(?P<id>\d+)'
  6. _TEST = {}
  7. _URL_TEMPLATE = 'https://%s.23video.com/%s/%s/%s/%s/download-video.mp4'
  8. _FORMATS = {
  9. 'video_hd': {
  10. 'width': 1280,
  11. 'height': 720,
  12. },
  13. 'video_medium': {
  14. 'width': 640,
  15. 'height': 360,
  16. },
  17. 'video_mobile_high': {
  18. 'width': 320,
  19. 'height': 180,
  20. }
  21. }
  22. def _extract_formats(self, url, client_id):
  23. client_name = self._search_regex(r'([a-z]+)\.23video\.com', url, 'client name')
  24. video_id = self._search_regex(r'photo%5fid=([^?&]+)', url, 'video id')
  25. token = self._search_regex(r'token=([^?&]+)', url, 'token')
  26. formats = []
  27. for format_key in self._FORMATS.keys():
  28. formats.append({
  29. 'url': self._URL_TEMPLATE % (client_name, client_id, video_id,
  30. token, format_key),
  31. 'width': self._FORMATS.get(format_key, {}).get('width'),
  32. 'height': self._FORMATS.get(format_key, {}).get('height'),
  33. })
  34. return formats
  35. def _real_extract(self, url):
  36. # TODO: Find out how to extract client_id
  37. raise NotImplementedError('Not able to extract the `client_id`')