]>
Commit | Line | Data |
---|---|---|
6cb38a99 PH |
1 | from __future__ import unicode_literals |
2 | ||
6cb38a99 PH |
3 | from .common import InfoExtractor |
4 | ||
5 | ||
6 | class FirstpostIE(InfoExtractor): | |
5886b38d | 7 | _VALID_URL = r'https?://(?:www\.)?firstpost\.com/[^/]+/.*-(?P<id>[0-9]+)\.html' |
6cb38a99 PH |
8 | |
9 | _TEST = { | |
10 | 'url': 'http://www.firstpost.com/india/india-to-launch-indigenous-aircraft-carrier-monday-1025403.html', | |
11 | 'md5': 'ee9114957692f01fb1263ed87039112a', | |
12 | 'info_dict': { | |
13 | 'id': '1025403', | |
14 | 'ext': 'mp4', | |
15 | 'title': 'India to launch indigenous aircraft carrier INS Vikrant today', | |
d2824416 | 16 | 'description': 'md5:feef3041cb09724e0bdc02843348f5f4', |
6cb38a99 PH |
17 | } |
18 | } | |
19 | ||
20 | def _real_extract(self, url): | |
c0e1a415 | 21 | video_id = self._match_id(url) |
d2824416 | 22 | page = self._download_webpage(url, video_id) |
c0e1a415 PH |
23 | |
24 | title = self._html_search_meta('twitter:title', page, 'title', fatal=True) | |
d2824416 S |
25 | description = self._html_search_meta('twitter:description', page, 'title') |
26 | ||
6a4f3528 S |
27 | data = self._download_xml( |
28 | 'http://www.firstpost.com/getvideoxml-%s.xml' % video_id, video_id, | |
29 | 'Downloading video XML') | |
30 | ||
31 | item = data.find('./playlist/item') | |
32 | thumbnail = item.find('./image').text | |
6a4f3528 S |
33 | |
34 | formats = [ | |
35 | { | |
36 | 'url': details.find('./file').text, | |
37 | 'format_id': details.find('./label').text.strip(), | |
38 | 'width': int(details.find('./width').text.strip()), | |
39 | 'height': int(details.find('./height').text.strip()), | |
40 | } for details in item.findall('./source/file_details') if details.find('./file').text | |
41 | ] | |
c0e1a415 | 42 | self._sort_formats(formats) |
6cb38a99 PH |
43 | |
44 | return { | |
45 | 'id': video_id, | |
6a4f3528 | 46 | 'title': title, |
d2824416 | 47 | 'description': description, |
6a4f3528 S |
48 | 'thumbnail': thumbnail, |
49 | 'formats': formats, | |
6cb38a99 | 50 | } |