]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/ntvru.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
  10 class NTVRuIE(InfoExtractor
): 
  12     _VALID_URL 
= r
'http://(?:www\.)?ntv\.ru/(?P<id>.+)' 
  16             'url': 'http://www.ntv.ru/novosti/863142/', 
  20                 'title': 'Командующий Черноморским флотом провел переговоры в штабе ВМС Украины', 
  21                 'description': 'Командующий Черноморским флотом провел переговоры в штабе ВМС Украины', 
  26                 'skip_download': True, 
  30             'url': 'http://www.ntv.ru/video/novosti/750370/', 
  34                 'title': 'Родные пассажиров пропавшего Boeing не верят в трагический исход', 
  35                 'description': 'Родные пассажиров пропавшего Boeing не верят в трагический исход', 
  40                 'skip_download': True, 
  44             'url': 'http://www.ntv.ru/peredacha/segodnya/m23700/o232416', 
  48                 'title': '«Сегодня». 21 марта 2014 года. 16:00 ', 
  49                 'description': '«Сегодня». 21 марта 2014 года. 16:00 ', 
  54                 'skip_download': True, 
  58             'url': 'http://www.ntv.ru/kino/Koma_film', 
  62                 'title': 'Остросюжетный фильм «Кома»', 
  63                 'description': 'Остросюжетный фильм «Кома»', 
  68                 'skip_download': True, 
  72             'url': 'http://www.ntv.ru/serial/Delo_vrachey/m31760/o233916/', 
  76                 'title': '«Дело врачей»: «Деревце жизни»', 
  77                 'description': '«Дело врачей»: «Деревце жизни»', 
  82                 'skip_download': True, 
  88         r
'<meta property="og:url" content="http://www\.ntv\.ru/video/(\d+)', 
  89         r
'<video embed=[^>]+><id>(\d+)</id>', 
  90         r
'<video restriction[^>]+><key>(\d+)</key>', 
  93     def _real_extract(self
, url
): 
  94         video_id 
= self
._match
_id
(url
) 
  95         page 
= self
._download
_webpage
(url
, video_id
) 
  97         video_id 
= self
._html
_search
_regex
(self
._VIDEO
_ID
_REGEXES
, page
, 'video id') 
  99         player 
= self
._download
_xml
('http://www.ntv.ru/vi%s/' % video_id
, video_id
, 'Downloading video XML') 
 100         title 
= unescapeHTML(player
.find('./data/title').text
) 
 101         description 
= unescapeHTML(player
.find('./data/description').text
) 
 103         video 
= player
.find('./data/video') 
 104         video_id 
= video
.find('./id').text
 
 105         thumbnail 
= video
.find('./splash').text
 
 106         duration 
= int(video
.find('./totaltime').text
) 
 107         view_count 
= int(video
.find('./views').text
) 
 108         puid22 
= video
.find('./puid22').text
 
 115         app 
= apps
.get(puid22
, apps
['4']) 
 118         for format_id 
in ['', 'hi', 'webm']: 
 119             file = video
.find('./%sfile' % format_id
) 
 122             size 
= video
.find('./%ssize' % format_id
) 
 124                 'url': 'rtmp://media.ntv.ru/%s' % app
, 
 126                 'play_path': file.text
, 
 128                 'player_url': 'http://www.ntv.ru/swf/vps1.swf?update=20131128', 
 129                 'page_url': 'http://www.ntv.ru', 
 130                 'flash_version': 'LNX 11,2,202,341', 
 133                 'filesize': int(size
.text
), 
 135         self
._sort
_formats
(formats
) 
 140             'description': description
, 
 141             'thumbnail': thumbnail
, 
 142             'duration': duration
, 
 143             'view_count': view_count
,