]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/firstpost.py
debian/changelog: Annotate bugs to close.
[youtubedl] / youtube_dl / extractor / firstpost.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4
5
6 class FirstpostIE(InfoExtractor):
7 _VALID_URL = r'http://(?:www\.)?firstpost\.com/[^/]+/.*-(?P<id>[0-9]+)\.html'
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',
16 'description': 'md5:feef3041cb09724e0bdc02843348f5f4',
17 }
18 }
19
20 def _real_extract(self, url):
21 video_id = self._match_id(url)
22 page = self._download_webpage(url, video_id)
23
24 title = self._html_search_meta('twitter:title', page, 'title', fatal=True)
25 description = self._html_search_meta('twitter:description', page, 'title')
26
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
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 ]
42 self._sort_formats(formats)
43
44 return {
45 'id': video_id,
46 'title': title,
47 'description': description,
48 'thumbnail': thumbnail,
49 'formats': formats,
50 }