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