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