2 from __future__ import unicode_literals
7 from .common import InfoExtractor
10 compat_urllib_request,
20 class DCNGeneralIE(InfoExtractor):
21 _VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?show/(?P<show_id>\d+)/[^/]+(?:/(?P<video_id>\d+)/(?P<season_id>\d+))?'
23 def _real_extract(self, url):
24 show_id, video_id, season_id = re.match(self._VALID_URL, url).groups()
27 if video_id and int(video_id) > 0:
28 url = 'http://www.dcndigital.ae/#/media/%s' % video_id
32 if season_id and int(season_id) > 0:
33 url = smuggle_url('http://www.dcndigital.ae/#/program/season/%s' % season_id, {'show_id': show_id})
35 url = 'http://www.dcndigital.ae/#/program/%s' % show_id
43 class DCNVideoIE(InfoExtractor):
45 _VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?(?:video/[^/]+|media|catchup/[^/]+/[^/]+)/(?P<id>\d+)'
47 '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',
52 'title': 'رحلة العمر : الحلقة 1',
53 'description': 'md5:0156e935d870acb8ef0a66d24070c6d6',
54 'thumbnail': 're:^https?://.*\.jpg$',
56 'timestamp': 1227504126,
57 'upload_date': '20081124',
61 'skip_download': True,
65 def _real_extract(self, url):
66 video_id = self._match_id(url)
68 request = compat_urllib_request.Request(
69 'http://admin.mangomolo.com/analytics/index.php/plus/video?id=%s' % video_id,
70 headers={'Origin': 'http://www.dcndigital.ae'})
72 video = self._download_json(request, video_id)
73 title = video.get('title_en') or video['title_ar']
75 webpage = self._download_webpage(
76 'http://admin.mangomolo.com/analytics/index.php/customers/embed/video?'
77 + compat_urllib_parse.urlencode({
79 'user_id': video['user_id'],
80 'signature': video['signature'],
85 m3u8_url = self._html_search_regex(r'file:\s*"([^"]+)', webpage, 'm3u8 url')
86 formats = self._extract_m3u8_formats(
87 m3u8_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls')
89 rtsp_url = self._search_regex(
90 r'<a[^>]+href="(rtsp://[^"]+)"', webpage, 'rtsp url', fatal=False)
97 self._sort_formats(formats)
99 img = video.get('img')
100 thumbnail = 'http://admin.mangomolo.com/analytics/%s' % img if img else None
101 duration = int_or_none(video.get('duration'))
102 description = video.get('description_en') or video.get('description_ar')
103 timestamp = parse_iso8601(video.get('create_time') or video.get('update_time'), ' ')
108 'description': description,
109 'thumbnail': thumbnail,
110 'duration': duration,
111 'timestamp': timestamp,
116 class DCNLiveIE(InfoExtractor):
118 _VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?live/(?P<id>\d+)'
120 'url': 'http://www.dcndigital.ae/#/live/6/dubai-tv',
125 'title': 'Dubai Al Oula',
129 'skip_download': True,
133 def _real_extract(self, url):
134 channel_id = self._match_id(url)
136 request = compat_urllib_request.Request(
137 'http://admin.mangomolo.com/analytics/index.php/plus/getchanneldetails?channel_id=%s' % channel_id,
138 headers={'Origin': 'http://www.dcndigital.ae'})
140 channel = self._download_json(request, channel_id)
141 title = channel.get('title_en') or channel['title_ar']
143 webpage = self._download_webpage(
144 'http://admin.mangomolo.com/analytics/index.php/customers/embed/index?'
145 + compat_urllib_parse.urlencode({
146 'id': base64.b64encode(channel['user_id'].encode()).decode(),
147 'channelid': base64.b64encode(channel['id'].encode()).decode(),
148 'signature': channel['signature'],
153 m3u8_url = self._html_search_regex(r'file:\s*"([^"]+)', webpage, 'm3u8 url')
154 formats = self._extract_m3u8_formats(
155 m3u8_url, channel_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls')
157 rtsp_url = self._search_regex(
158 r'<a[^>]+href="(rtsp://[^"]+)"', webpage, 'rtsp url', fatal=False)
165 self._sort_formats(formats)
175 class DCNSeasonIE(InfoExtractor):
176 IE_NAME = 'dcn:season'
177 _VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?program/(?:(?P<show_id>\d+)|season/(?P<season_id>\d+))'
179 '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',
183 'title': 'محاضرات الشيخ الشعراوي',
186 'playlist_mincount': 27,
189 def _real_extract(self, url):
190 url, smuggled_data = unsmuggle_url(url, {})
191 show_id, season_id = re.match(self._VALID_URL, url).groups()
194 data['season'] = season_id
195 show_id = smuggled_data.get('show_id')
197 request = compat_urllib_request.Request(
198 'http://admin.mangomolo.com/analytics/index.php/plus/season_info?id=%s' % season_id,
199 headers={'Origin': 'http://www.dcndigital.ae'})
200 season = self._download_json(request, season_id)
201 show_id = season['id']
202 data['show_id'] = show_id
203 request = compat_urllib_request.Request(
204 'http://admin.mangomolo.com/analytics/index.php/plus/show',
205 compat_urllib_parse.urlencode(data),
207 'Origin': 'http://www.dcndigital.ae',
208 'Content-Type': 'application/x-www-form-urlencoded'
210 show = self._download_json(request, show_id)
211 season_id = season_id or show['default_season']
212 title = show['cat'].get('title_en') or show['cat']['title_ar']
213 description = show['cat'].get('description_en') or show['cat'].get('description_ar')
215 for video in show['videos']:
217 'url': 'http://www.dcndigital.ae/#/media/%s' % video['id'],
219 'ie_key': 'DCNVideo',
224 'description': description,