]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/presstv.py
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
   7 from ..utils 
import remove_start
 
  10 class PressTVIE(InfoExtractor
): 
  11     _VALID_URL 
= r
'https?://(?:www\.)?presstv\.ir/[^/]+/(?P<y>\d+)/(?P<m>\d+)/(?P<d>\d+)/(?P<id>\d+)/(?P<display_id>[^/]+)?' 
  14         'url': 'http://www.presstv.ir/Detail/2016/04/09/459911/Australian-sewerage-treatment-facility-/', 
  15         'md5': '5d7e3195a447cb13e9267e931d8dd5a5', 
  18             'display_id': 'Australian-sewerage-treatment-facility-', 
  20             'title': 'Organic mattresses used to clean waste water', 
  21             'upload_date': '20160409', 
  22             'thumbnail': r
're:^https?://.*\.jpg', 
  23             'description': 'md5:20002e654bbafb6908395a5c0cfcd125' 
  27     def _real_extract(self
, url
): 
  28         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  29         video_id 
= mobj
.group('id') 
  30         display_id 
= mobj
.group('display_id') or video_id
 
  32         webpage 
= self
._download
_webpage
(url
, display_id
) 
  34         # extract video URL from webpage 
  35         video_url 
= self
._hidden
_inputs
(webpage
)['inpPlayback'] 
  37         # build list of available formats 
  38         # specified in http://www.presstv.ir/Scripts/playback.js 
  39         base_url 
= 'http://192.99.219.222:82/presstv' 
  48             'url': base_url 
+ video_url
[:-4] + extension
, 
  49             'format_id': '%dp' % height
, 
  51         } for height
, extension 
in _formats
] 
  53         # extract video metadata 
  55             self
._html
_search
_meta
('title', webpage
, fatal
=True), 'PressTV-') 
  57         thumbnail 
= self
._og
_search
_thumbnail
(webpage
) 
  58         description 
= self
._og
_search
_description
(webpage
) 
  60         upload_date 
= '%04d%02d%02d' % ( 
  68             'display_id': display_id
, 
  71             'thumbnail': thumbnail
, 
  72             'upload_date': upload_date
, 
  73             'description': description