]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tass.py
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
  13 class TassIE(InfoExtractor
): 
  14     _VALID_URL 
= r
'https?://(?:tass\.ru|itar-tass\.com)/[^/]+/(?P<id>\d+)' 
  17             'url': 'http://tass.ru/obschestvo/1586870', 
  18             'md5': '3b4cdd011bc59174596b6145cda474a4', 
  22                 'title': 'Посетителям московского зоопарка показали красную панду', 
  23                 'description': 'Приехавшую из Дублина Зейну можно увидеть в павильоне "Кошки тропиков"', 
  24                 'thumbnail': r
're:^https?://.*\.jpg$', 
  28             'url': 'http://itar-tass.com/obschestvo/1600009', 
  29             'only_matching': True, 
  33     def _real_extract(self
, url
): 
  34         video_id 
= self
._match
_id
(url
) 
  36         webpage 
= self
._download
_webpage
(url
, video_id
) 
  38         sources 
= json
.loads(js_to_json(self
._search
_regex
( 
  39             r
'(?s)sources\s*:\s*(\[.+?\])', webpage
, 'sources'))) 
  41         quality 
= qualities(['sd', 'hd']) 
  44         for source 
in sources
: 
  45             video_url 
= source
.get('file') 
  46             if not video_url 
or not video_url
.startswith('http') or not video_url
.endswith('.mp4'): 
  48             label 
= source
.get('label') 
  52                 'quality': quality(label
), 
  54         self
._sort
_formats
(formats
) 
  58             'title': self
._og
_search
_title
(webpage
), 
  59             'description': self
._og
_search
_description
(webpage
), 
  60             'thumbnail': self
._og
_search
_thumbnail
(webpage
),