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 return self.url_result('http://www.dcndigital.ae/#/media/%s' % video_id, 'DCNVideo')
30 if season_id and int(season_id) > 0:
31 url = smuggle_url('http://www.dcndigital.ae/#/program/season/%s' % season_id, {'show_id': show_id})
33 url = 'http://www.dcndigital.ae/#/program/%s' % show_id
34 return self.url_result(url, 'DCNSeason')
37 class DCNVideoIE(InfoExtractor):
39 _VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?(?:video/[^/]+|media|catchup/[^/]+/[^/]+)/(?P<id>\d+)'
41 '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',
46 'title': 'رحلة العمر : الحلقة 1',
47 'description': 'md5:0156e935d870acb8ef0a66d24070c6d6',
48 'thumbnail': 're:^https?://.*\.jpg$',
50 'timestamp': 1227504126,
51 'upload_date': '20081124',
55 'skip_download': True,
59 def _real_extract(self, url):
60 video_id = self._match_id(url)
62 request = compat_urllib_request.Request(
63 'http://admin.mangomolo.com/analytics/index.php/plus/video?id=%s' % video_id,
64 headers={'Origin': 'http://www.dcndigital.ae'})
66 video = self._download_json(request, video_id)
67 title = video.get('title_en') or video['title_ar']
68 img = video.get('img')
69 thumbnail = 'http://admin.mangomolo.com/analytics/%s' % img if img else None
70 duration = int_or_none(video.get('duration'))
71 description = video.get('description_en') or video.get('description_ar')
72 timestamp = parse_iso8601(video.get('create_time') or video.get('update_time'), ' ')
74 webpage = self._download_webpage(
75 'http://admin.mangomolo.com/analytics/index.php/customers/embed/video?'
76 + compat_urllib_parse.urlencode({
78 'user_id': video['user_id'],
79 'signature': video['signature'],
84 m3u8_url = self._html_search_regex(r'file:\s*"([^"]+)', webpage, 'm3u8 url')
85 formats = self._extract_m3u8_formats(
86 m3u8_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls')
88 rtsp_url = self._search_regex(
89 r'<a[^>]+href="(rtsp://[^"]+)"', webpage, 'rtsp url', fatal=False)
96 self._sort_formats(formats)
101 'description': description,
102 'thumbnail': thumbnail,
103 'duration': duration,
104 'timestamp': timestamp,
109 class DCNLiveIE(InfoExtractor):
111 _VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?live/(?P<id>\d+)'
113 'url': 'http://www.dcndigital.ae/#/live/6/dubai-tv',
118 'title': 're:^Dubai Al Oula [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
119 'thumbnail': 're:^https?://.*\.png$',
124 'skip_download': True,
128 def _real_extract(self, url):
129 channel_id = self._match_id(url)
131 request = compat_urllib_request.Request(
132 'http://admin.mangomolo.com/analytics/index.php/plus/getchanneldetails?channel_id=%s' % channel_id,
133 headers={'Origin': 'http://www.dcndigital.ae'})
135 channel = self._download_json(request, channel_id)
136 title = channel.get('title_en') or channel['title_ar']
137 img = channel.get('thumbnail')
138 thumbnail = 'http://admin.mangomolo.com/analytics/%s' % img if img else None
139 description = channel.get('description_en') or channel.get('description_ar')
140 timestamp = parse_iso8601(channel.get('create_time') or channel.get('update_time'), ' ')
142 webpage = self._download_webpage(
143 'http://admin.mangomolo.com/analytics/index.php/customers/embed/index?' +
144 compat_urllib_parse.urlencode({
145 'id': base64.b64encode(channel['user_id'].encode()).decode(),
146 'channelid': base64.b64encode(channel['id'].encode()).decode(),
147 'signature': channel['signature'],
152 m3u8_url = self._html_search_regex(r'file:\s*"([^"]+)', webpage, 'm3u8 url')
153 formats = self._extract_m3u8_formats(
154 m3u8_url, channel_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls')
156 rtsp_url = self._search_regex(
157 r'<a[^>]+href="(rtsp://[^"]+)"', webpage, 'rtsp url', fatal=False)
164 self._sort_formats(formats)
168 'title': self._live_title(title),
169 'description': description,
170 'thumbnail': thumbnail,
176 class DCNSeasonIE(InfoExtractor):
177 IE_NAME = 'dcn:season'
178 _VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?program/(?:(?P<show_id>\d+)|season/(?P<season_id>\d+))'
180 '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',
184 '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()
195 data['season'] = season_id
196 show_id = smuggled_data.get('show_id')
198 request = compat_urllib_request.Request(
199 'http://admin.mangomolo.com/analytics/index.php/plus/season_info?id=%s' % season_id,
200 headers={'Origin': 'http://www.dcndigital.ae'})
201 season = self._download_json(request, season_id)
202 show_id = season['id']
203 data['show_id'] = show_id
204 request = compat_urllib_request.Request(
205 'http://admin.mangomolo.com/analytics/index.php/plus/show',
206 compat_urllib_parse.urlencode(data),
208 'Origin': 'http://www.dcndigital.ae',
209 'Content-Type': 'application/x-www-form-urlencoded'
212 show = self._download_json(request, show_id)
214 season_id = show['default_season']
215 for season in show['seasons']:
216 if season['id'] == season_id:
217 title = season.get('title_en') or season['title_ar']
220 for video in show['videos']:
221 entries.append(self.url_result('http://www.dcndigital.ae/#/media/%s' % video['id'], 'DCNVideo'))
223 return self.playlist_result(entries, season_id, title)