]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/ntv.py
ed60314eca4f918392da7fe2637e47ed3cdf5ee9
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
  12 class NTVIE(InfoExtractor
): 
  13     _VALID_URL 
= r
'http://(?:www\.)?ntv\.ru/(?P<id>.+)' 
  17             'url': 'http://www.ntv.ru/novosti/863142/', 
  21                 'title': 'Командующий Черноморским флотом провел переговоры в штабе ВМС Украины', 
  22                 'description': 'Командующий Черноморским флотом провел переговоры в штабе ВМС Украины', 
  27                 'skip_download': True, 
  31             'url': 'http://www.ntv.ru/video/novosti/750370/', 
  35                 'title': 'Родные пассажиров пропавшего Boeing не верят в трагический исход', 
  36                 'description': 'Родные пассажиров пропавшего Boeing не верят в трагический исход', 
  41                 'skip_download': True, 
  45             'url': 'http://www.ntv.ru/peredacha/segodnya/m23700/o232416', 
  49                 'title': '«Сегодня». 21 марта 2014 года. 16:00 ', 
  50                 'description': '«Сегодня». 21 марта 2014 года. 16:00 ', 
  55                 'skip_download': True, 
  59             'url': 'http://www.ntv.ru/kino/Koma_film', 
  63                 'title': 'Остросюжетный фильм «Кома»', 
  64                 'description': 'Остросюжетный фильм «Кома»', 
  69                 'skip_download': True, 
  73             'url': 'http://www.ntv.ru/serial/Delo_vrachey/m31760/o233916/', 
  77                 'title': '«Дело врачей»: «Деревце жизни»', 
  78                 'description': '«Дело врачей»: «Деревце жизни»', 
  83                 'skip_download': True, 
  89         r
'<meta property="og:url" content="http://www\.ntv\.ru/video/(\d+)', 
  90         r
'<video embed=[^>]+><id>(\d+)</id>', 
  91         r
'<video restriction[^>]+><key>(\d+)</key>', 
  94     def _real_extract(self
, url
): 
  95         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  96         video_id 
= mobj
.group('id') 
  98         page 
= self
._download
_webpage
(url
, video_id
) 
 100         video_id 
= self
._html
_search
_regex
(self
._VIDEO
_ID
_REGEXES
, page
, 'video id') 
 102         player 
= self
._download
_xml
('http://www.ntv.ru/vi%s/' % video_id
, video_id
, 'Downloading video XML') 
 103         title 
= unescapeHTML(player
.find('./data/title').text
) 
 104         description 
= unescapeHTML(player
.find('./data/description').text
) 
 106         video 
= player
.find('./data/video') 
 107         video_id 
= video
.find('./id').text
 
 108         thumbnail 
= video
.find('./splash').text
 
 109         duration 
= int(video
.find('./totaltime').text
) 
 110         view_count 
= int(video
.find('./views').text
) 
 111         puid22 
= video
.find('./puid22').text
 
 118         app 
= apps
.get(puid22
, apps
['4']) 
 121         for format_id 
in ['', 'hi', 'webm']: 
 122             file = video
.find('./%sfile' % format_id
) 
 125             size 
= video
.find('./%ssize' % format_id
) 
 127                 'url': 'rtmp://media.ntv.ru/%s' % app
, 
 129                 'play_path': file.text
, 
 131                 'player_url': 'http://www.ntv.ru/swf/vps1.swf?update=20131128', 
 132                 'page_url': 'http://www.ntv.ru', 
 133                 'flash_ver': 'LNX 11,2,202,341', 
 136                 'filesize': int(size
.text
), 
 138         self
._sort
_formats
(formats
) 
 143             'description': description
, 
 144             'thumbnail': thumbnail
, 
 145             'duration': duration
, 
 146             'view_count': view_count
,