]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tvigle.py
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
  15 class TvigleIE(InfoExtractor
): 
  17     IE_DESC 
= 'Интернет-телевидение Tvigle.ru' 
  18     _VALID_URL 
= r
'https?://(?:www\.)?(?:tvigle\.ru/(?:[^/]+/)+(?P<display_id>[^/]+)/$|cloud\.tvigle\.ru/video/(?P<id>\d+))' 
  22             'url': 'http://www.tvigle.ru/video/sokrat/', 
  23             'md5': '36514aed3657d4f70b4b2cef8eb520cd', 
  26                 'display_id': 'sokrat', 
  29                 'description': 'md5:d6b92ffb7217b4b8ebad2e7665253c17', 
  33             'skip': 'georestricted', 
  36             'url': 'http://www.tvigle.ru/video/vladimir-vysotskii/vedushchii-teleprogrammy-60-minut-ssha-o-vladimire-vysotskom/', 
  37             'md5': 'e7efe5350dd5011d0de6550b53c3ba7b', 
  41                 'title': 'Ведущий телепрограммы «60 минут» (США) о Владимире Высоцком', 
  42                 'description': 'md5:027f7dc872948f14c96d19b4178428a4', 
  46             'skip': 'georestricted', 
  48             'url': 'https://cloud.tvigle.ru/video/5267604/', 
  49             'only_matching': True, 
  53     def _real_extract(self
, url
): 
  54         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  55         video_id 
= mobj
.group('id') 
  56         display_id 
= mobj
.group('display_id') 
  59             webpage 
= self
._download
_webpage
(url
, display_id
) 
  60             video_id 
= self
._html
_search
_regex
( 
  61                 (r
'<div[^>]+class=["\']player
["\'][^>]+id=["\'](\d
+)', 
  62                  r'var\s
+cloudId\s
*=\s
*["\'](\d+)', 
  63                  r'class="video
-preview current_playing
" id="(\d
+)"'), 
  66         video_data = self._download_json( 
  67             'http://cloud.tvigle.ru/api/play/video/%s/' % video_id, display_id) 
  69         item = video_data['playlist']['items'][0] 
  71         videos = item.get('videos') 
  73         error_message = item.get('errorMessage') 
  74         if not videos and error_message: 
  76                 '%s returned error: %s' % (self.IE_NAME, error_message), expected=True) 
  79         description = item.get('description') 
  80         thumbnail = item.get('thumbnail') 
  81         duration = float_or_none(item.get('durationMilliseconds'), 1000) 
  82         age_limit = parse_age_limit(item.get('ageRestrictions')) 
  85         for vcodec, fmts in item['videos'].items(): 
  88             for format_id, video_url in fmts.items(): 
  89                 if format_id == 'm3u8': 
  91                 height = self._search_regex( 
  92                     r'^(\d+)[pP]$', format_id, 'height', default=None) 
  95                     'format_id': '%s-%s' % (vcodec, format_id), 
  97                     'height': int_or_none(height), 
  98                     'filesize': int_or_none(item.get('video_files_size', {}).get(vcodec, {}).get(format_id)), 
 100         self._sort_formats(formats) 
 104             'display_id': display_id, 
 106             'description': description, 
 107             'thumbnail': thumbnail, 
 108             'duration': duration, 
 109             'age_limit': age_limit,