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.

56 lines
2.1 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import int_or_none
  6. class MinotoIE(InfoExtractor):
  7. _VALID_URL = r'(?:minoto:|https?://(?:play|iframe|embed)\.minoto-video\.com/(?P<player_id>[0-9]+)/)(?P<id>[a-zA-Z0-9]+)'
  8. def _real_extract(self, url):
  9. mobj = re.match(self._VALID_URL, url)
  10. player_id = mobj.group('player_id') or '1'
  11. video_id = mobj.group('id')
  12. video_data = self._download_json('http://play.minoto-video.com/%s/%s.js' % (player_id, video_id), video_id)
  13. video_metadata = video_data['video-metadata']
  14. formats = []
  15. for fmt in video_data['video-files']:
  16. fmt_url = fmt.get('url')
  17. if not fmt_url:
  18. continue
  19. container = fmt.get('container')
  20. if container == 'hls':
  21. formats.extend(fmt_url, video_id, 'mp4', m3u8_id='hls', fatal=False)
  22. else:
  23. fmt_profile = fmt.get('profile') or {}
  24. f = {
  25. 'format_id': fmt_profile.get('name-short'),
  26. 'format_note': fmt_profile.get('name'),
  27. 'url': fmt_url,
  28. 'container': container,
  29. 'tbr': int_or_none(fmt.get('bitrate')),
  30. 'filesize': int_or_none(fmt.get('filesize')),
  31. 'width': int_or_none(fmt.get('width')),
  32. 'height': int_or_none(fmt.get('height')),
  33. }
  34. codecs = fmt.get('codecs')
  35. if codecs:
  36. codecs = codecs.split(',')
  37. if len(codecs) == 2:
  38. f.update({
  39. 'vcodec': codecs[0],
  40. 'acodec': codecs[1],
  41. })
  42. formats.append(f)
  43. self._sort_formats(formats)
  44. return {
  45. 'id': video_id,
  46. 'title': video_metadata['title'],
  47. 'description': video_metadata.get('description'),
  48. 'thumbnail': video_metadata.get('video-poster', {}).get('url'),
  49. 'formats': formats,
  50. }