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