]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/firstpost.py
   1 from __future__ 
import unicode_literals
 
   3 from .common 
import InfoExtractor
 
   6 class FirstpostIE(InfoExtractor
): 
   7     _VALID_URL 
= r
'http://(?:www\.)?firstpost\.com/[^/]+/.*-(?P<id>[0-9]+)\.html' 
  10         'url': 'http://www.firstpost.com/india/india-to-launch-indigenous-aircraft-carrier-monday-1025403.html', 
  11         'md5': 'ee9114957692f01fb1263ed87039112a', 
  15             'title': 'India to launch indigenous aircraft carrier INS Vikrant today', 
  16             'description': 'md5:feef3041cb09724e0bdc02843348f5f4', 
  20     def _real_extract(self
, url
): 
  21         video_id 
= self
._match
_id
(url
) 
  22         page 
= self
._download
_webpage
(url
, video_id
) 
  24         title 
= self
._html
_search
_meta
('twitter:title', page
, 'title', fatal
=True) 
  25         description 
= self
._html
_search
_meta
('twitter:description', page
, 'title') 
  27         data 
= self
._download
_xml
( 
  28             'http://www.firstpost.com/getvideoxml-%s.xml' % video_id
, video_id
, 
  29             'Downloading video XML') 
  31         item 
= data
.find('./playlist/item') 
  32         thumbnail 
= item
.find('./image').text
 
  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
 
  42         self
._sort
_formats
(formats
) 
  47             'description': description
, 
  48             'thumbnail': thumbnail
,