]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tvigle.py
3475ef4c3b91b69c136c53e251a25d3d902152f3
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+))'
21 _GEO_COUNTRIES
= ['RU']
25 'url': 'http://www.tvigle.ru/video/sokrat/',
26 'md5': '36514aed3657d4f70b4b2cef8eb520cd',
29 'display_id': 'sokrat',
32 'description': 'md5:d6b92ffb7217b4b8ebad2e7665253c17',
36 'skip': 'georestricted',
39 'url': 'http://www.tvigle.ru/video/vladimir-vysotskii/vedushchii-teleprogrammy-60-minut-ssha-o-vladimire-vysotskom/',
40 'md5': 'e7efe5350dd5011d0de6550b53c3ba7b',
44 'title': 'Ведущий телепрограммы «60 минут» (США) о Владимире Высоцком',
45 'description': 'md5:027f7dc872948f14c96d19b4178428a4',
49 'skip': 'georestricted',
51 'url': 'https://cloud.tvigle.ru/video/5267604/',
52 'only_matching': True,
56 def _real_extract(self
, url
):
57 mobj
= re
.match(self
._VALID
_URL
, url
)
58 video_id
= mobj
.group('id')
59 display_id
= mobj
.group('display_id')
62 webpage
= self
._download
_webpage
(url
, display_id
)
63 video_id
= self
._html
_search
_regex
(
64 (r
'<div[^>]+class=["\']player
["\'][^>]+id=["\'](\d
+)',
65 r'var\s
+cloudId\s
*=\s
*["\'](\d+)',
66 r'class="video
-preview current_playing
" id="(\d
+)"'),
69 video_data = self._download_json(
70 'http://cloud.tvigle.ru/api/play/video/%s/' % video_id, display_id)
72 item = video_data['playlist']['items'][0]
74 videos = item.get('videos')
76 error_message = item.get('errorMessage')
77 if not videos and error_message:
78 if item.get('isGeoBlocked') is True:
79 self.raise_geo_restricted(
80 msg=error_message, countries=self._GEO_COUNTRIES)
83 '%s returned error: %s' % (self.IE_NAME, error_message),
87 description = item.get('description')
88 thumbnail = item.get('thumbnail')
89 duration = float_or_none(item.get('durationMilliseconds'), 1000)
90 age_limit = parse_age_limit(item.get('ageRestrictions'))
93 for vcodec, fmts in item['videos'].items():
96 for format_id, video_url in fmts.items():
97 if format_id == 'm3u8':
99 height = self._search_regex(
100 r'^(\d+)[pP]$', format_id, 'height', default=None)
103 'format_id': '%s-%s' % (vcodec, format_id),
105 'height': int_or_none(height),
106 'filesize': int_or_none(item.get('video_files_size', {}).get(vcodec, {}).get(format_id)),
108 self._sort_formats(formats)
112 'display_id': display_id,
114 'description': description,
115 'thumbnail': thumbnail,
116 'duration': duration,
117 'age_limit': age_limit,