2 from __future__ import unicode_literals
4 from .common import InfoExtractor
5 from ..utils import int_or_none
6 from ..compat import compat_urlparse
9 class DWIE(InfoExtractor):
11 _VALID_URL = r'https?://(?:www\.)?dw\.com/(?:[^/]+/)+av-(?P<id>\d+)'
14 'url': 'http://www.dw.com/en/intelligent-light/av-19112290',
15 'md5': '7372046e1815c5a534b43f3c3c36e6e9',
19 'title': 'Intelligent light',
20 'description': 'md5:90e00d5881719f2a6a5827cb74985af1',
21 'upload_date': '20160311',
25 'url': 'http://www.dw.com/en/worldlink-my-business/av-19111941',
26 'md5': '2814c9a1321c3a51f8a7aeb067a360dd',
30 'title': 'WorldLink: My business',
31 'description': 'md5:bc9ca6e4e063361e21c920c53af12405',
32 'upload_date': '20160311',
36 def _real_extract(self, url):
37 media_id = self._match_id(url)
38 webpage = self._download_webpage(url, media_id)
39 hidden_inputs = self._hidden_inputs(webpage)
40 title = hidden_inputs['media_title']
42 if hidden_inputs.get('player_type') == 'video' and hidden_inputs.get('stream_file') == '1':
43 formats = self._extract_smil_formats(
44 'http://www.dw.com/smil/v-%s' % media_id, media_id,
45 transform_source=lambda s: s.replace(
46 'rtmp://tv-od.dw.de/flash/',
47 'http://tv-download.dw.de/dwtv_video/flv/'))
48 self._sort_formats(formats)
50 formats = [{'url': hidden_inputs['file_name']}]
55 'description': self._og_search_description(webpage),
56 'thumbnail': hidden_inputs.get('preview_image'),
57 'duration': int_or_none(hidden_inputs.get('file_duration')),
58 'upload_date': hidden_inputs.get('display_date'),
63 class DWArticleIE(InfoExtractor):
64 IE_NAME = 'dw:article'
65 _VALID_URL = r'https?://(?:www\.)?dw\.com/(?:[^/]+/)+a-(?P<id>\d+)'
67 'url': 'http://www.dw.com/en/no-hope-limited-options-for-refugees-in-idomeni/a-19111009',
68 'md5': '8ca657f9d068bbef74d6fc38b97fc869',
72 'title': 'The harsh life of refugees in Idomeni',
73 'description': 'md5:196015cc7e48ebf474db9399420043c7',
74 'upload_date': '20160310',
78 def _real_extract(self, url):
79 article_id = self._match_id(url)
80 webpage = self._download_webpage(url, article_id)
81 hidden_inputs = self._hidden_inputs(webpage)
82 media_id = hidden_inputs['media_id']
83 media_path = self._search_regex(r'href="([^"]+av-%s)"\s+class="overlayLink"' % media_id, webpage, 'media url')
84 media_url = compat_urlparse.urljoin(url, media_path)
85 return self.url_result(media_url, 'DW', media_id)