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.

81 lines
2.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. parse_duration,
  7. parse_iso8601,
  8. )
  9. class MnetIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?mnet\.(?:com|interest\.me)/tv/vod/(?:.*?\bclip_id=)?(?P<id>[0-9]+)'
  11. _TESTS = [{
  12. 'url': 'http://www.mnet.com/tv/vod/171008',
  13. 'info_dict': {
  14. 'id': '171008',
  15. 'title': 'SS_이해인@히든박스',
  16. 'description': 'md5:b9efa592c3918b615ba69fe9f8a05c55',
  17. 'duration': 88,
  18. 'upload_date': '20151231',
  19. 'timestamp': 1451564040,
  20. 'age_limit': 0,
  21. 'thumbnails': 'mincount:5',
  22. 'thumbnail': r're:^https?://.*\.jpg$',
  23. 'ext': 'flv',
  24. },
  25. 'params': {
  26. # rtmp download
  27. 'skip_download': True,
  28. },
  29. }, {
  30. 'url': 'http://mnet.interest.me/tv/vod/172790',
  31. 'only_matching': True,
  32. }, {
  33. 'url': 'http://www.mnet.com/tv/vod/vod_view.asp?clip_id=172790&tabMenu=',
  34. 'only_matching': True,
  35. }]
  36. def _real_extract(self, url):
  37. video_id = self._match_id(url)
  38. info = self._download_json(
  39. 'http://content.api.mnet.com/player/vodConfig?id=%s&ctype=CLIP' % video_id,
  40. video_id, 'Downloading vod config JSON')['data']['info']
  41. title = info['title']
  42. rtmp_info = self._download_json(
  43. info['cdn'], video_id, 'Downloading vod cdn JSON')
  44. formats = [{
  45. 'url': rtmp_info['serverurl'] + rtmp_info['fileurl'],
  46. 'ext': 'flv',
  47. 'page_url': url,
  48. 'player_url': 'http://flvfile.mnet.com/service/player/201602/cjem_player_tv.swf?v=201602191318',
  49. }]
  50. description = info.get('ment')
  51. duration = parse_duration(info.get('time'))
  52. timestamp = parse_iso8601(info.get('date'), delimiter=' ')
  53. age_limit = info.get('adult')
  54. if age_limit is not None:
  55. age_limit = 0 if age_limit == 'N' else 18
  56. thumbnails = [{
  57. 'id': thumb_format,
  58. 'url': thumb['url'],
  59. 'width': int_or_none(thumb.get('width')),
  60. 'height': int_or_none(thumb.get('height')),
  61. } for thumb_format, thumb in info.get('cover', {}).items() if thumb.get('url')]
  62. return {
  63. 'id': video_id,
  64. 'title': title,
  65. 'description': description,
  66. 'duration': duration,
  67. 'timestamp': timestamp,
  68. 'age_limit': age_limit,
  69. 'thumbnails': thumbnails,
  70. 'formats': formats,
  71. }