]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/ntvru.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
  12 class NTVRuIE(InfoExtractor
): 
  14     _VALID_URL 
= r
'http://(?:www\.)?ntv\.ru/(?P<id>.+)' 
  18             'url': 'http://www.ntv.ru/novosti/863142/', 
  19             'md5': 'ba7ea172a91cb83eb734cad18c10e723', 
  23                 'title': 'Командующий Черноморским флотом провел переговоры в штабе ВМС Украины', 
  24                 'description': 'Командующий Черноморским флотом провел переговоры в штабе ВМС Украины', 
  25                 'thumbnail': 're:^http://.*\.jpg', 
  30             'url': 'http://www.ntv.ru/video/novosti/750370/', 
  31             'md5': 'adecff79691b4d71e25220a191477124', 
  35                 'title': 'Родные пассажиров пропавшего Boeing не верят в трагический исход', 
  36                 'description': 'Родные пассажиров пропавшего Boeing не верят в трагический исход', 
  37                 'thumbnail': 're:^http://.*\.jpg', 
  42             'url': 'http://www.ntv.ru/peredacha/segodnya/m23700/o232416', 
  43             'md5': '82dbd49b38e3af1d00df16acbeab260c', 
  47                 'title': '«Сегодня». 21 марта 2014 года. 16:00', 
  48                 'description': '«Сегодня». 21 марта 2014 года. 16:00', 
  49                 'thumbnail': 're:^http://.*\.jpg', 
  54             'url': 'http://www.ntv.ru/kino/Koma_film', 
  55             'md5': 'f825770930937aa7e5aca0dc0d29319a', 
  59                 'title': 'Остросюжетный фильм «Кома»', 
  60                 'description': 'Остросюжетный фильм «Кома»', 
  61                 'thumbnail': 're:^http://.*\.jpg', 
  66             'url': 'http://www.ntv.ru/serial/Delo_vrachey/m31760/o233916/', 
  67             'md5': '9320cd0e23f3ea59c330dc744e06ff3b', 
  71                 'title': '«Дело врачей»: «Деревце жизни»', 
  72                 'description': '«Дело врачей»: «Деревце жизни»', 
  73                 'thumbnail': 're:^http://.*\.jpg', 
  80         r
'<meta property="og:url" content="http://www\.ntv\.ru/video/(\d+)', 
  81         r
'<video embed=[^>]+><id>(\d+)</id>', 
  82         r
'<video restriction[^>]+><key>(\d+)</key>', 
  85     def _real_extract(self
, url
): 
  86         video_id 
= self
._match
_id
(url
) 
  88         webpage 
= self
._download
_webpage
(url
, video_id
) 
  90         video_id 
= self
._html
_search
_regex
(self
._VIDEO
_ID
_REGEXES
, webpage
, 'video id') 
  92         player 
= self
._download
_xml
( 
  93             'http://www.ntv.ru/vi%s/' % video_id
, 
  94             video_id
, 'Downloading video XML') 
  95         title 
= clean_html(xpath_text(player
, './data/title', 'title', fatal
=True)) 
  96         description 
= clean_html(xpath_text(player
, './data/description', 'description')) 
  98         video 
= player
.find('./data/video') 
  99         video_id 
= xpath_text(video
, './id', 'video id') 
 100         thumbnail 
= xpath_text(video
, './splash', 'thumbnail') 
 101         duration 
= int_or_none(xpath_text(video
, './totaltime', 'duration')) 
 102         view_count 
= int_or_none(xpath_text(video
, './views', 'view count')) 
 104         token 
= self
._download
_webpage
( 
 105             'http://stat.ntv.ru/services/access/token', 
 106             video_id
, 'Downloading access token') 
 109         for format_id 
in ['', 'hi', 'webm']: 
 110             file_ 
= video
.find('./%sfile' % format_id
) 
 113             size 
= video
.find('./%ssize' % format_id
) 
 115                 'url': 'http://media2.ntv.ru/vod/%s&tok=%s' % (file_
.text
, token
), 
 116                 'filesize': int_or_none(size
.text 
if size 
is not None else None), 
 118         self
._sort
_formats
(formats
) 
 123             'description': description
, 
 124             'thumbnail': thumbnail
, 
 125             'duration': duration
, 
 126             'view_count': view_count
,