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.

192 lines
7.3 KiB

Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
9 years ago
Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
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. import re
  4. import base64
  5. from .common import InfoExtractor
  6. from ..compat import compat_urllib_parse
  7. from ..utils import (
  8. int_or_none,
  9. parse_iso8601,
  10. sanitized_Request,
  11. smuggle_url,
  12. unsmuggle_url,
  13. )
  14. class DCNIE(InfoExtractor):
  15. _VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?show/(?P<show_id>\d+)/[^/]+(?:/(?P<video_id>\d+)/(?P<season_id>\d+))?'
  16. def _real_extract(self, url):
  17. show_id, video_id, season_id = re.match(self._VALID_URL, url).groups()
  18. if video_id and int(video_id) > 0:
  19. return self.url_result(
  20. 'http://www.dcndigital.ae/media/%s' % video_id, 'DCNVideo')
  21. elif season_id and int(season_id) > 0:
  22. return self.url_result(smuggle_url(
  23. 'http://www.dcndigital.ae/program/season/%s' % season_id,
  24. {'show_id': show_id}), 'DCNSeason')
  25. else:
  26. return self.url_result(
  27. 'http://www.dcndigital.ae/program/%s' % show_id, 'DCNSeason')
  28. class DCNBaseIE(InfoExtractor):
  29. def _extract_video_info(self, video_data, video_id, is_live):
  30. title = video_data.get('title_en') or video_data['title_ar']
  31. img = video_data.get('img')
  32. thumbnail = 'http://admin.mangomolo.com/analytics/%s' % img if img else None
  33. duration = int_or_none(video_data.get('duration'))
  34. description = video_data.get('description_en') or video_data.get('description_ar')
  35. timestamp = parse_iso8601(video_data.get('create_time'), ' ')
  36. return {
  37. 'id': video_id,
  38. 'title': self._live_title(title) if is_live else title,
  39. 'description': description,
  40. 'thumbnail': thumbnail,
  41. 'duration': duration,
  42. 'timestamp': timestamp,
  43. 'is_live': is_live,
  44. }
  45. def _extract_video_formats(self, webpage, video_id, entry_protocol):
  46. formats = []
  47. m3u8_url = self._html_search_regex(
  48. r'file\s*:\s*"([^"]+)', webpage, 'm3u8 url', fatal=False)
  49. if m3u8_url:
  50. formats.extend(self._extract_m3u8_formats(
  51. m3u8_url, video_id, 'mp4', entry_protocol, m3u8_id='hls', fatal=None))
  52. rtsp_url = self._search_regex(
  53. r'<a[^>]+href="(rtsp://[^"]+)"', webpage, 'rtsp url', fatal=False)
  54. if rtsp_url:
  55. formats.append({
  56. 'url': rtsp_url,
  57. 'format_id': 'rtsp',
  58. })
  59. self._sort_formats(formats)
  60. return formats
  61. class DCNVideoIE(DCNBaseIE):
  62. IE_NAME = 'dcn:video'
  63. _VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?(?:video/[^/]+|media|catchup/[^/]+/[^/]+)/(?P<id>\d+)'
  64. _TEST = {
  65. 'url': 'http://www.dcndigital.ae/#/video/%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',
  66. 'info_dict':
  67. {
  68. 'id': '17375',
  69. 'ext': 'mp4',
  70. 'title': 'رحلة العمر : الحلقة 1',
  71. 'description': 'md5:0156e935d870acb8ef0a66d24070c6d6',
  72. 'duration': 2041,
  73. 'timestamp': 1227504126,
  74. 'upload_date': '20081124',
  75. },
  76. 'params': {
  77. # m3u8 download
  78. 'skip_download': True,
  79. },
  80. }
  81. def _real_extract(self, url):
  82. video_id = self._match_id(url)
  83. request = sanitized_Request(
  84. 'http://admin.mangomolo.com/analytics/index.php/plus/video?id=%s' % video_id,
  85. headers={'Origin': 'http://www.dcndigital.ae'})
  86. video_data = self._download_json(request, video_id)
  87. info = self._extract_video_info(video_data, video_id, False)
  88. webpage = self._download_webpage(
  89. 'http://admin.mangomolo.com/analytics/index.php/customers/embed/video?' +
  90. compat_urllib_parse.urlencode({
  91. 'id': video_data['id'],
  92. 'user_id': video_data['user_id'],
  93. 'signature': video_data['signature'],
  94. 'countries': 'Q0M=',
  95. 'filter': 'DENY',
  96. }), video_id)
  97. info['formats'] = self._extract_video_formats(webpage, video_id, 'm3u8_native')
  98. return info
  99. class DCNLiveIE(DCNBaseIE):
  100. IE_NAME = 'dcn:live'
  101. _VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?live/(?P<id>\d+)'
  102. def _real_extract(self, url):
  103. channel_id = self._match_id(url)
  104. request = sanitized_Request(
  105. 'http://admin.mangomolo.com/analytics/index.php/plus/getchanneldetails?channel_id=%s' % channel_id,
  106. headers={'Origin': 'http://www.dcndigital.ae'})
  107. channel_data = self._download_json(request, channel_id)
  108. info = self._extract_video_info(channel_data, channel_id, True)
  109. webpage = self._download_webpage(
  110. 'http://admin.mangomolo.com/analytics/index.php/customers/embed/index?' +
  111. compat_urllib_parse.urlencode({
  112. 'id': base64.b64encode(channel_data['user_id'].encode()).decode(),
  113. 'channelid': base64.b64encode(channel_data['id'].encode()).decode(),
  114. 'signature': channel_data['signature'],
  115. 'countries': 'Q0M=',
  116. 'filter': 'DENY',
  117. }), channel_id)
  118. info['formats'] = self._extract_video_formats(webpage, channel_id, 'm3u8')
  119. return info
  120. class DCNSeasonIE(InfoExtractor):
  121. IE_NAME = 'dcn:season'
  122. _VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?program/(?:(?P<show_id>\d+)|season/(?P<season_id>\d+))'
  123. _TEST = {
  124. 'url': 'http://dcndigital.ae/#/program/205024/%D9%85%D8%AD%D8%A7%D8%B6%D8%B1%D8%A7%D8%AA-%D8%A7%D9%84%D8%B4%D9%8A%D8%AE-%D8%A7%D9%84%D8%B4%D8%B9%D8%B1%D8%A7%D9%88%D9%8A',
  125. 'info_dict':
  126. {
  127. 'id': '7910',
  128. 'title': 'محاضرات الشيخ الشعراوي',
  129. },
  130. 'playlist_mincount': 27,
  131. }
  132. def _real_extract(self, url):
  133. url, smuggled_data = unsmuggle_url(url, {})
  134. show_id, season_id = re.match(self._VALID_URL, url).groups()
  135. data = {}
  136. if season_id:
  137. data['season'] = season_id
  138. show_id = smuggled_data.get('show_id')
  139. if show_id is None:
  140. request = sanitized_Request(
  141. 'http://admin.mangomolo.com/analytics/index.php/plus/season_info?id=%s' % season_id,
  142. headers={'Origin': 'http://www.dcndigital.ae'})
  143. season = self._download_json(request, season_id)
  144. show_id = season['id']
  145. data['show_id'] = show_id
  146. request = sanitized_Request(
  147. 'http://admin.mangomolo.com/analytics/index.php/plus/show',
  148. compat_urllib_parse.urlencode(data),
  149. {
  150. 'Origin': 'http://www.dcndigital.ae',
  151. 'Content-Type': 'application/x-www-form-urlencoded'
  152. })
  153. show = self._download_json(request, show_id)
  154. if not season_id:
  155. season_id = show['default_season']
  156. for season in show['seasons']:
  157. if season['id'] == season_id:
  158. title = season.get('title_en') or season['title_ar']
  159. entries = []
  160. for video in show['videos']:
  161. entries.append(self.url_result(
  162. 'http://www.dcndigital.ae/media/%s' % video['id'], 'DCNVideo'))
  163. return self.playlist_result(entries, season_id, title)