]>
Commit | Line | Data |
---|---|---|
cd6b555e | 1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
8e2898ed | 4 | import base64 |
9f4921bf | 5 | |
3af1fac7 | 6 | from .common import InfoExtractor |
3fc088f8 | 7 | from ..compat import ( |
15707c7e | 8 | compat_urllib_parse_urlencode, |
3fc088f8 | 9 | compat_str, |
10 | ) | |
f94639fa S |
11 | from ..utils import ( |
12 | int_or_none, | |
13 | parse_iso8601, | |
b477da20 | 14 | smuggle_url, |
15 | unsmuggle_url, | |
6e6bc8da | 16 | urlencode_postdata, |
f94639fa | 17 | ) |
cd6b555e | 18 | |
3af1fac7 | 19 | |
7367bdef | 20 | class AWAANIE(InfoExtractor): |
d3d8d818 | 21 | _VALID_URL = r'https?://(?:www\.)?(?:awaan|dcndigital)\.ae/(?:#/)?show/(?P<show_id>\d+)/[^/]+(?:/(?P<id>\d+)/(?P<season_id>\d+))?' |
9f4921bf | 22 | |
23 | def _real_extract(self, url): | |
5ad28e7f | 24 | show_id, video_id, season_id = self._match_valid_url(url).groups() |
9f4921bf | 25 | if video_id and int(video_id) > 0: |
6afe044b | 26 | return self.url_result( |
7367bdef | 27 | 'http://awaan.ae/media/%s' % video_id, 'AWAANVideo') |
6afe044b | 28 | elif season_id and int(season_id) > 0: |
29 | return self.url_result(smuggle_url( | |
7367bdef RA |
30 | 'http://awaan.ae/program/season/%s' % season_id, |
31 | {'show_id': show_id}), 'AWAANSeason') | |
9f4921bf | 32 | else: |
6afe044b | 33 | return self.url_result( |
7367bdef | 34 | 'http://awaan.ae/program/%s' % show_id, 'AWAANSeason') |
9f4921bf | 35 | |
36 | ||
7367bdef RA |
37 | class AWAANBaseIE(InfoExtractor): |
38 | def _parse_video_data(self, video_data, video_id, is_live): | |
6afe044b | 39 | title = video_data.get('title_en') or video_data['title_ar'] |
40 | img = video_data.get('img') | |
6afe044b | 41 | |
42 | return { | |
43 | 'id': video_id, | |
44 | 'title': self._live_title(title) if is_live else title, | |
7367bdef RA |
45 | 'description': video_data.get('description_en') or video_data.get('description_ar'), |
46 | 'thumbnail': 'http://admin.mangomolo.com/analytics/%s' % img if img else None, | |
47 | 'duration': int_or_none(video_data.get('duration')), | |
48 | 'timestamp': parse_iso8601(video_data.get('create_time'), ' '), | |
6afe044b | 49 | 'is_live': is_live, |
2181983a | 50 | 'uploader_id': video_data.get('user_id'), |
6afe044b | 51 | } |
52 | ||
6afe044b | 53 | |
7367bdef RA |
54 | class AWAANVideoIE(AWAANBaseIE): |
55 | IE_NAME = 'awaan:video' | |
8065d6c5 RA |
56 | _VALID_URL = r'https?://(?:www\.)?(?:awaan|dcndigital)\.ae/(?:#/)?(?:video(?:/[^/]+)?|media|catchup/[^/]+/[^/]+)/(?P<id>\d+)' |
57 | _TESTS = [{ | |
9f4921bf | 58 | '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', |
7367bdef | 59 | 'md5': '5f61c33bfc7794315c671a62d43116aa', |
3af1fac7 | 60 | 'info_dict': |
61 | { | |
62 | 'id': '17375', | |
f94639fa | 63 | 'ext': 'mp4', |
3af1fac7 | 64 | 'title': 'رحلة العمر : الحلقة 1', |
f94639fa | 65 | 'description': 'md5:0156e935d870acb8ef0a66d24070c6d6', |
f94639fa S |
66 | 'duration': 2041, |
67 | 'timestamp': 1227504126, | |
68 | 'upload_date': '20081124', | |
93933c98 | 69 | 'uploader_id': '71', |
cd6b555e | 70 | }, |
8065d6c5 RA |
71 | }, { |
72 | 'url': 'http://awaan.ae/video/26723981/%D8%AF%D8%A7%D8%B1-%D8%A7%D9%84%D8%B3%D9%84%D8%A7%D9%85:-%D8%AE%D9%8A%D8%B1-%D8%AF%D9%88%D8%B1-%D8%A7%D9%84%D8%A3%D9%86%D8%B5%D8%A7%D8%B1', | |
73 | 'only_matching': True, | |
74 | }] | |
3af1fac7 | 75 | |
76 | def _real_extract(self, url): | |
77 | video_id = self._match_id(url) | |
f94639fa | 78 | |
7367bdef | 79 | video_data = self._download_json( |
f94639fa | 80 | 'http://admin.mangomolo.com/analytics/index.php/plus/video?id=%s' % video_id, |
7367bdef RA |
81 | video_id, headers={'Origin': 'http://awaan.ae'}) |
82 | info = self._parse_video_data(video_data, video_id, False) | |
f94639fa | 83 | |
7d273a38 RA |
84 | embed_url = 'http://admin.mangomolo.com/analytics/index.php/customers/embed/video?' + compat_urllib_parse_urlencode({ |
85 | 'id': video_data['id'], | |
86 | 'user_id': video_data['user_id'], | |
87 | 'signature': video_data['signature'], | |
88 | 'countries': 'Q0M=', | |
89 | 'filter': 'DENY', | |
90 | }) | |
91 | info.update({ | |
92 | '_type': 'url_transparent', | |
93 | 'url': embed_url, | |
94 | 'ie_key': 'MangomoloVideo', | |
95 | }) | |
6afe044b | 96 | return info |
f94639fa | 97 | |
f94639fa | 98 | |
7367bdef RA |
99 | class AWAANLiveIE(AWAANBaseIE): |
100 | IE_NAME = 'awaan:live' | |
8065d6c5 | 101 | _VALID_URL = r'https?://(?:www\.)?(?:awaan|dcndigital)\.ae/(?:#/)?live/(?P<id>\d+)' |
7367bdef RA |
102 | _TEST = { |
103 | 'url': 'http://awaan.ae/live/6/dubai-tv', | |
104 | 'info_dict': { | |
105 | 'id': '6', | |
106 | 'ext': 'mp4', | |
107 | 'title': 're:Dubai Al Oula [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$', | |
108 | 'upload_date': '20150107', | |
109 | 'timestamp': 1420588800, | |
2181983a | 110 | 'uploader_id': '71', |
7367bdef RA |
111 | }, |
112 | 'params': { | |
113 | # m3u8 download | |
114 | 'skip_download': True, | |
115 | }, | |
116 | } | |
8e2898ed | 117 | |
118 | def _real_extract(self, url): | |
119 | channel_id = self._match_id(url) | |
120 | ||
7367bdef | 121 | channel_data = self._download_json( |
8e2898ed | 122 | 'http://admin.mangomolo.com/analytics/index.php/plus/getchanneldetails?channel_id=%s' % channel_id, |
7367bdef RA |
123 | channel_id, headers={'Origin': 'http://awaan.ae'}) |
124 | info = self._parse_video_data(channel_data, channel_id, True) | |
8e2898ed | 125 | |
7d273a38 RA |
126 | embed_url = 'http://admin.mangomolo.com/analytics/index.php/customers/embed/index?' + compat_urllib_parse_urlencode({ |
127 | 'id': base64.b64encode(channel_data['user_id'].encode()).decode(), | |
128 | 'channelid': base64.b64encode(channel_data['id'].encode()).decode(), | |
129 | 'signature': channel_data['signature'], | |
130 | 'countries': 'Q0M=', | |
131 | 'filter': 'DENY', | |
132 | }) | |
133 | info.update({ | |
134 | '_type': 'url_transparent', | |
135 | 'url': embed_url, | |
136 | 'ie_key': 'MangomoloLive', | |
137 | }) | |
6afe044b | 138 | return info |
8e2898ed | 139 | |
140 | ||
7367bdef RA |
141 | class AWAANSeasonIE(InfoExtractor): |
142 | IE_NAME = 'awaan:season' | |
8065d6c5 | 143 | _VALID_URL = r'https?://(?:www\.)?(?:awaan|dcndigital)\.ae/(?:#/)?program/(?:(?P<show_id>\d+)|season/(?P<season_id>\d+))' |
9f4921bf | 144 | _TEST = { |
145 | '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', | |
146 | 'info_dict': | |
147 | { | |
b477da20 | 148 | 'id': '7910', |
9f4921bf | 149 | 'title': 'محاضرات الشيخ الشعراوي', |
9f4921bf | 150 | }, |
151 | 'playlist_mincount': 27, | |
152 | } | |
153 | ||
154 | def _real_extract(self, url): | |
b477da20 | 155 | url, smuggled_data = unsmuggle_url(url, {}) |
5ad28e7f | 156 | show_id, season_id = self._match_valid_url(url).groups() |
48637515 | 157 | |
9f4921bf | 158 | data = {} |
159 | if season_id: | |
9f4921bf | 160 | data['season'] = season_id |
b477da20 | 161 | show_id = smuggled_data.get('show_id') |
162 | if show_id is None: | |
7367bdef | 163 | season = self._download_json( |
b477da20 | 164 | 'http://admin.mangomolo.com/analytics/index.php/plus/season_info?id=%s' % season_id, |
7367bdef | 165 | season_id, headers={'Origin': 'http://awaan.ae'}) |
b477da20 | 166 | show_id = season['id'] |
9f4921bf | 167 | data['show_id'] = show_id |
7367bdef | 168 | show = self._download_json( |
9f4921bf | 169 | 'http://admin.mangomolo.com/analytics/index.php/plus/show', |
7367bdef RA |
170 | show_id, data=urlencode_postdata(data), headers={ |
171 | 'Origin': 'http://awaan.ae', | |
9f4921bf | 172 | 'Content-Type': 'application/x-www-form-urlencoded' |
f94639fa | 173 | }) |
50b9dd73 | 174 | if not season_id: |
175 | season_id = show['default_season'] | |
176 | for season in show['seasons']: | |
177 | if season['id'] == season_id: | |
178 | title = season.get('title_en') or season['title_ar'] | |
f94639fa | 179 | |
50b9dd73 | 180 | entries = [] |
181 | for video in show['videos']: | |
3fc088f8 | 182 | video_id = compat_str(video['id']) |
6afe044b | 183 | entries.append(self.url_result( |
7367bdef | 184 | 'http://awaan.ae/media/%s' % video_id, 'AWAANVideo', video_id)) |
f94639fa | 185 | |
50b9dd73 | 186 | return self.playlist_result(entries, season_id, title) |