]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/tvigle.py
1 from .common
import InfoExtractor
12 class TvigleIE(InfoExtractor
):
14 IE_DESC
= 'Интернет-телевидение Tvigle.ru'
15 _VALID_URL
= r
'https?://(?:www\.)?(?:tvigle\.ru/(?:[^/]+/)+(?P<display_id>[^/]+)/$|cloud\.tvigle\.ru/video/(?P<id>\d+))'
18 _GEO_COUNTRIES
= ['RU']
22 'url': 'http://www.tvigle.ru/video/sokrat/',
25 'display_id': 'sokrat',
28 'description': 'md5:d6b92ffb7217b4b8ebad2e7665253c17',
32 'skip': 'georestricted',
35 'url': 'http://www.tvigle.ru/video/vladimir-vysotskii/vedushchii-teleprogrammy-60-minut-ssha-o-vladimire-vysotskom/',
39 'title': 'Ведущий телепрограммы «60 минут» (США) о Владимире Высоцком',
40 'description': 'md5:027f7dc872948f14c96d19b4178428a4',
44 'skip': 'georestricted',
46 'url': 'https://cloud.tvigle.ru/video/5267604/',
47 'only_matching': True,
51 def _real_extract(self
, url
):
52 mobj
= self
._match
_valid
_url
(url
)
53 video_id
= mobj
.group('id')
54 display_id
= mobj
.group('display_id')
57 webpage
= self
._download
_webpage
(url
, display_id
)
58 video_id
= self
._html
_search
_regex
(
59 (r
'<div[^>]+class=["\']player
["\'][^>]+id=["\'](\d
+)',
60 r'cloudId\s
*=\s
*["\'](\d+)',
61 r'class="video
-preview current_playing
" id="(\d
+)"'),
64 video_data = self._download_json(
65 'http://cloud.tvigle.ru/api/play/video/%s/' % video_id, display_id)
67 item = video_data['playlist']['items'][0]
69 videos = item.get('videos')
71 error_message = item.get('errorMessage')
72 if not videos and error_message:
73 if item.get('isGeoBlocked') is True:
74 self.raise_geo_restricted(
75 msg=error_message, countries=self._GEO_COUNTRIES)
78 '%s returned error: %s' % (self.IE_NAME, error_message),
82 description = item.get('description')
83 thumbnail = item.get('thumbnail')
84 duration = float_or_none(item.get('durationMilliseconds'), 1000)
85 age_limit = parse_age_limit(item.get('ageRestrictions'))
88 for vcodec, url_or_fmts in item['videos'].items():
90 m3u8_url = url_or_none(url_or_fmts)
93 formats.extend(self._extract_m3u8_formats(
94 m3u8_url, video_id, ext='mp4', entry_protocol='m3u8_native',
95 m3u8_id='hls', fatal=False))
96 elif vcodec == 'dash':
97 mpd_url = url_or_none(url_or_fmts)
100 formats.extend(self._extract_mpd_formats(
101 mpd_url, video_id, mpd_id='dash', fatal=False))
103 if not isinstance(url_or_fmts, dict):
105 for format_id, video_url in url_or_fmts.items():
106 if format_id == 'm3u8':
108 video_url = url_or_none(video_url)
111 height = self._search_regex(
112 r'^(\d+)[pP]$', format_id, 'height', default=None)
113 filesize = int_or_none(try_get(
114 item, lambda x: x['video_files_size'][vcodec][format_id]))
117 'format_id': '%s-%s' % (vcodec, format_id),
119 'height': int_or_none(height),
120 'filesize': filesize,
122 self._sort_formats(formats)
126 'display_id': display_id,
128 'description': description,
129 'thumbnail': thumbnail,
130 'duration': duration,
131 'age_limit': age_limit,