]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/firstpost.py
Update changelog
[youtubedl] / youtube_dl / extractor / firstpost.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6
7
8 class FirstpostIE(InfoExtractor):
9 _VALID_URL = r'http://(?:www\.)?firstpost\.com/[^/]+/.*-(?P<id>[0-9]+)\.html'
10
11 _TEST = {
12 'url': 'http://www.firstpost.com/india/india-to-launch-indigenous-aircraft-carrier-monday-1025403.html',
13 'md5': 'ee9114957692f01fb1263ed87039112a',
14 'info_dict': {
15 'id': '1025403',
16 'ext': 'mp4',
17 'title': 'India to launch indigenous aircraft carrier INS Vikrant today',
18 }
19 }
20
21 def _real_extract(self, url):
22 mobj = re.match(self._VALID_URL, url)
23 video_id = mobj.group('id')
24
25 data = self._download_xml(
26 'http://www.firstpost.com/getvideoxml-%s.xml' % video_id, video_id,
27 'Downloading video XML')
28
29 item = data.find('./playlist/item')
30 thumbnail = item.find('./image').text
31 title = item.find('./title').text
32
33 formats = [
34 {
35 'url': details.find('./file').text,
36 'format_id': details.find('./label').text.strip(),
37 'width': int(details.find('./width').text.strip()),
38 'height': int(details.find('./height').text.strip()),
39 } for details in item.findall('./source/file_details') if details.find('./file').text
40 ]
41
42 return {
43 'id': video_id,
44 'title': title,
45 'thumbnail': thumbnail,
46 'formats': formats,
47 }