]>
Commit | Line | Data |
---|---|---|
cd6b555e | 1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
3af1fac7 | 4 | from .common import InfoExtractor |
5c2266df | 5 | from ..compat import compat_urllib_parse |
f94639fa S |
6 | from ..utils import ( |
7 | int_or_none, | |
8 | parse_iso8601, | |
5c2266df | 9 | sanitized_Request, |
f94639fa | 10 | ) |
cd6b555e | 11 | |
3af1fac7 | 12 | |
f94639fa | 13 | class DCNIE(InfoExtractor): |
4a7434d0 | 14 | _VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?(?:video/.+|show/\d+/.+?)/(?P<id>\d+)' |
3af1fac7 | 15 | _TEST = { |
16 | 'url': 'http://www.dcndigital.ae/#/show/199074/%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/6887', | |
17 | 'info_dict': | |
18 | { | |
19 | 'id': '17375', | |
f94639fa | 20 | 'ext': 'mp4', |
3af1fac7 | 21 | 'title': 'رحلة العمر : الحلقة 1', |
f94639fa S |
22 | 'description': 'md5:0156e935d870acb8ef0a66d24070c6d6', |
23 | 'thumbnail': 're:^https?://.*\.jpg$', | |
24 | 'duration': 2041, | |
25 | 'timestamp': 1227504126, | |
26 | 'upload_date': '20081124', | |
cd6b555e | 27 | }, |
28 | 'params': { | |
29 | # m3u8 download | |
30 | 'skip_download': True, | |
31 | }, | |
3af1fac7 | 32 | } |
33 | ||
34 | def _real_extract(self, url): | |
35 | video_id = self._match_id(url) | |
f94639fa | 36 | |
5c2266df | 37 | request = sanitized_Request( |
f94639fa S |
38 | 'http://admin.mangomolo.com/analytics/index.php/plus/video?id=%s' % video_id, |
39 | headers={'Origin': 'http://www.dcndigital.ae'}) | |
40 | ||
41 | video = self._download_json(request, video_id) | |
42 | title = video.get('title_en') or video['title_ar'] | |
43 | ||
3af1fac7 | 44 | webpage = self._download_webpage( |
9dd73ef4 YCH |
45 | 'http://admin.mangomolo.com/analytics/index.php/customers/embed/video?' + |
46 | compat_urllib_parse.urlencode({ | |
f94639fa S |
47 | 'id': video['id'], |
48 | 'user_id': video['user_id'], | |
49 | 'signature': video['signature'], | |
50 | 'countries': 'Q0M=', | |
51 | 'filter': 'DENY', | |
52 | }), video_id) | |
53 | ||
54 | m3u8_url = self._html_search_regex(r'file:\s*"([^"]+)', webpage, 'm3u8 url') | |
55 | formats = self._extract_m3u8_formats( | |
56 | m3u8_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls') | |
57 | ||
58 | rtsp_url = self._search_regex( | |
59 | r'<a[^>]+href="(rtsp://[^"]+)"', webpage, 'rtsp url', fatal=False) | |
60 | if rtsp_url: | |
61 | formats.append({ | |
62 | 'url': rtsp_url, | |
63 | 'format_id': 'rtsp', | |
64 | }) | |
65 | ||
66 | self._sort_formats(formats) | |
67 | ||
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'), ' ') | |
73 | ||
3af1fac7 | 74 | return { |
75 | 'id': video_id, | |
76 | 'title': title, | |
f94639fa | 77 | 'description': description, |
3af1fac7 | 78 | 'thumbnail': thumbnail, |
79 | 'duration': duration, | |
f94639fa | 80 | 'timestamp': timestamp, |
3af1fac7 | 81 | 'formats': formats, |
82 | } |