]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/lifenews.py
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
  13 class LifeNewsIE(InfoExtractor
): 
  15     IE_DESC 
= 'LIFE | NEWS' 
  16     _VALID_URL 
= r
'http://lifenews\.ru/(?:mobile/)?news/(?P<id>\d+)' 
  19         'url': 'http://lifenews.ru/news/126342', 
  20         'md5': 'e1b50a5c5fb98a6a544250f2e0db570a', 
  24             'title': 'МВД разыскивает мужчин, оставивших в IKEA сумку с автоматом', 
  25             'description': 'Камеры наблюдения гипермаркета зафиксировали троих мужчин, спрятавших оружейный арсенал в камере хранения.', 
  26             'thumbnail': 'http://lifenews.ru/static/posts/2014/1/126342/.video.jpg', 
  27             'upload_date': '20140130', 
  31     def _real_extract(self
, url
): 
  32         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  33         video_id 
= mobj
.group('id') 
  35         webpage 
= self
._download
_webpage
('http://lifenews.ru/mobile/news/%s' % video_id
, video_id
, 'Downloading page') 
  37         video_url 
= self
._html
_search
_regex
( 
  38             r
'<video.*?src="([^"]+)".*?></video>', webpage
, 'video URL') 
  40         thumbnail 
= self
._html
_search
_regex
( 
  41             r
'<video.*?poster="([^"]+)".*?"></video>', webpage
, 'video thumbnail') 
  43         title 
= self
._og
_search
_title
(webpage
) 
  44         TITLE_SUFFIX 
= ' - Первый по срочным новостям — LIFE | NEWS' 
  45         if title
.endswith(TITLE_SUFFIX
): 
  46             title 
= title
[:-len(TITLE_SUFFIX
)] 
  48         description 
= self
._og
_search
_description
(webpage
) 
  50         view_count 
= self
._html
_search
_regex
( 
  51             r
'<div class=\'views
\'>(\d
+)</div
>', webpage, 'view count
', fatal=False) 
  52         comment_count = self._html_search_regex( 
  53             r'<div 
class=\'comments
\'>(\d
+)</div
>', webpage, 'comment count
', fatal=False) 
  55         upload_date = self._html_search_regex( 
  56             r'<time datetime
=\'([^
\']+)\'>', webpage, 'upload date
',fatal=False) 
  57         if upload_date is not None: 
  58             upload_date = unified_strdate(upload_date) 
  63             'thumbnail
': thumbnail, 
  65             'description
': description, 
  66             'view_count
': int_or_none(view_count), 
  67             'comment_count
': int_or_none(comment_count), 
  68             'upload_date
': upload_date,