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.

84 lines
2.8 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import (
  5. compat_urllib_parse,
  6. compat_urllib_request,
  7. )
  8. from ..utils import (
  9. int_or_none,
  10. parse_iso8601,
  11. )
  12. class DCNIE(InfoExtractor):
  13. _VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?(?:video/.+|show/\d+/.+?)/(?P<id>\d+)'
  14. _TEST = {
  15. 'url': 'http://www.dcndigital.ae/#/show/199074/%D8%B1%D8%AD%D9%84%D8%A9-%D8%A7%D9%84%D8%B9%D9%85%D8%B1-%D8%A7%D9%84%D8%AD%D9%84%D9%82%D8%A9-1/17375/6887',
  16. 'info_dict':
  17. {
  18. 'id': '17375',
  19. 'ext': 'mp4',
  20. 'title': 'رحلة العمر : الحلقة 1',
  21. 'description': 'md5:0156e935d870acb8ef0a66d24070c6d6',
  22. 'thumbnail': 're:^https?://.*\.jpg$',
  23. 'duration': 2041,
  24. 'timestamp': 1227504126,
  25. 'upload_date': '20081124',
  26. },
  27. 'params': {
  28. # m3u8 download
  29. 'skip_download': True,
  30. },
  31. }
  32. def _real_extract(self, url):
  33. video_id = self._match_id(url)
  34. request = compat_urllib_request.Request(
  35. 'http://admin.mangomolo.com/analytics/index.php/plus/video?id=%s' % video_id,
  36. headers={'Origin': 'http://www.dcndigital.ae'})
  37. video = self._download_json(request, video_id)
  38. title = video.get('title_en') or video['title_ar']
  39. webpage = self._download_webpage(
  40. 'http://admin.mangomolo.com/analytics/index.php/customers/embed/video?' +
  41. compat_urllib_parse.urlencode({
  42. 'id': video['id'],
  43. 'user_id': video['user_id'],
  44. 'signature': video['signature'],
  45. 'countries': 'Q0M=',
  46. 'filter': 'DENY',
  47. }), video_id)
  48. m3u8_url = self._html_search_regex(r'file:\s*"([^"]+)', webpage, 'm3u8 url')
  49. formats = self._extract_m3u8_formats(
  50. m3u8_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls')
  51. rtsp_url = self._search_regex(
  52. r'<a[^>]+href="(rtsp://[^"]+)"', webpage, 'rtsp url', fatal=False)
  53. if rtsp_url:
  54. formats.append({
  55. 'url': rtsp_url,
  56. 'format_id': 'rtsp',
  57. })
  58. self._sort_formats(formats)
  59. img = video.get('img')
  60. thumbnail = 'http://admin.mangomolo.com/analytics/%s' % img if img else None
  61. duration = int_or_none(video.get('duration'))
  62. description = video.get('description_en') or video.get('description_ar')
  63. timestamp = parse_iso8601(video.get('create_time') or video.get('update_time'), ' ')
  64. return {
  65. 'id': video_id,
  66. 'title': title,
  67. 'description': description,
  68. 'thumbnail': thumbnail,
  69. 'duration': duration,
  70. 'timestamp': timestamp,
  71. 'formats': formats,
  72. }