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.

60 lines
1.9 KiB

10 years ago
10 years ago
10 years ago
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import int_or_none
  4. class MporaIE(InfoExtractor):
  5. _VALID_URL = r'https?://(www\.)?mpora\.(?:com|de)/videos/(?P<id>[^?#/]+)'
  6. IE_NAME = 'MPORA'
  7. _TEST = {
  8. 'url': 'http://mpora.de/videos/AAdo8okx4wiz/embed?locale=de',
  9. 'md5': 'a7a228473eedd3be741397cf452932eb',
  10. 'info_dict': {
  11. 'id': 'AAdo8okx4wiz',
  12. 'ext': 'mp4',
  13. 'title': 'Katy Curd - Winter in the Forest',
  14. 'duration': 416,
  15. 'uploader': 'Peter Newman Media',
  16. },
  17. }
  18. def _real_extract(self, url):
  19. video_id = self._match_id(url)
  20. webpage = self._download_webpage(url, video_id)
  21. data_json = self._search_regex(
  22. r"new FM\.Player\('[^']+',\s*(\{.*?)\).player;", webpage, 'json')
  23. data = self._parse_json(data_json, video_id)
  24. uploader = data['info_overlay'].get('username')
  25. duration = data['video']['duration'] // 1000
  26. thumbnail = data['video']['encodings']['sd']['poster']
  27. title = data['info_overlay']['title']
  28. formats = []
  29. for encoding_id, edata in data['video']['encodings'].items():
  30. for src in edata['sources']:
  31. width_str = self._search_regex(
  32. r'_([0-9]+)\.[a-zA-Z0-9]+$', src['src'],
  33. False, default=None)
  34. vcodec = src['type'].partition('/')[2]
  35. formats.append({
  36. 'format_id': encoding_id + '-' + vcodec,
  37. 'url': src['src'],
  38. 'vcodec': vcodec,
  39. 'width': int_or_none(width_str),
  40. })
  41. self._sort_formats(formats)
  42. return {
  43. 'id': video_id,
  44. 'title': title,
  45. 'formats': formats,
  46. 'uploader': uploader,
  47. 'duration': duration,
  48. 'thumbnail': thumbnail,
  49. }