]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/tvigle.py
2 from __future__
import unicode_literals
5 from .common
import InfoExtractor
16 class TvigleIE(InfoExtractor
):
18 IE_DESC
= 'Интернет-телевидение Tvigle.ru'
19 _VALID_URL
= r
'https?://(?:www\.)?(?:tvigle\.ru/(?:[^/]+/)+(?P<display_id>[^/]+)/$|cloud\.tvigle\.ru/video/(?P<id>\d+))'
22 _GEO_COUNTRIES
= ['RU']
26 'url': 'http://www.tvigle.ru/video/sokrat/',
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/',
43 'title': 'Ведущий телепрограммы «60 минут» (США) о Владимире Высоцком',
44 'description': 'md5:027f7dc872948f14c96d19b4178428a4',
48 'skip': 'georestricted',
50 'url': 'https://cloud.tvigle.ru/video/5267604/',
51 'only_matching': True,
55 def _real_extract(self
, url
):
56 mobj
= self
._match
_valid
_url
(url
)
57 video_id
= mobj
.group('id')
58 display_id
= mobj
.group('display_id')
61 webpage
= self
._download
_webpage
(url
, display_id
)
62 video_id
= self
._html
_search
_regex
(
63 (r
'<div[^>]+class=["\']player
["\'][^>]+id=["\'](\d
+)',
64 r'cloudId\s
*=\s
*["\'](\d+)',
65 r'class="video
-preview current_playing
" id="(\d
+)"'),
68 video_data = self._download_json(
69 'http://cloud.tvigle.ru/api/play/video/%s/' % video_id, display_id)
71 item = video_data['playlist']['items'][0]
73 videos = item.get('videos')
75 error_message = item.get('errorMessage')
76 if not videos and error_message:
77 if item.get('isGeoBlocked') is True:
78 self.raise_geo_restricted(
79 msg=error_message, countries=self._GEO_COUNTRIES)
82 '%s returned error: %s' % (self.IE_NAME, error_message),
86 description = item.get('description')
87 thumbnail = item.get('thumbnail')
88 duration = float_or_none(item.get('durationMilliseconds'), 1000)
89 age_limit = parse_age_limit(item.get('ageRestrictions'))
92 for vcodec, url_or_fmts in item['videos'].items():
94 m3u8_url = url_or_none(url_or_fmts)
97 formats.extend(self._extract_m3u8_formats(
98 m3u8_url, video_id, ext='mp4', entry_protocol='m3u8_native',
99 m3u8_id='hls', fatal=False))
100 elif vcodec == 'dash':
101 mpd_url = url_or_none(url_or_fmts)
104 formats.extend(self._extract_mpd_formats(
105 mpd_url, video_id, mpd_id='dash', fatal=False))
107 if not isinstance(url_or_fmts, dict):
109 for format_id, video_url in url_or_fmts.items():
110 if format_id == 'm3u8':
112 video_url = url_or_none(video_url)
115 height = self._search_regex(
116 r'^(\d+)[pP]$', format_id, 'height', default=None)
117 filesize = int_or_none(try_get(
118 item, lambda x: x['video_files_size'][vcodec][format_id]))
121 'format_id': '%s-%s' % (vcodec, format_id),
123 'height': int_or_none(height),
124 'filesize': filesize,
126 self._sort_formats(formats)
130 'display_id': display_id,
132 'description': description,
133 'thumbnail': thumbnail,
134 'duration': duration,
135 'age_limit': age_limit,