2015-06-07 16:25:30 +02:00
|
|
|
|
from .common import InfoExtractor
|
|
|
|
|
from ..utils import (
|
2015-06-12 12:13:36 +02:00
|
|
|
|
clean_html,
|
2015-06-07 16:25:30 +02:00
|
|
|
|
int_or_none,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2015-06-12 12:24:13 +02:00
|
|
|
|
class TVCIE(InfoExtractor):
|
2016-03-21 16:36:32 +01:00
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?tvc\.ru/video/iframe/id/(?P<id>\d+)'
|
2022-08-01 03:23:25 +02:00
|
|
|
|
_EMBED_REGEX = [r'<iframe[^>]+?src=(["\'])(?P<url>(?:http:)?//(?:www\.)?tvc\.ru/video/iframe/id/[^"]+)\1']
|
2015-06-12 12:13:36 +02:00
|
|
|
|
_TEST = {
|
|
|
|
|
'url': 'http://www.tvc.ru/video/iframe/id/74622/isPlay/false/id_stat/channel/?acc_video_id=/channel/brand/id/17/show/episodes/episode_id/39702',
|
|
|
|
|
'md5': 'bbc5ff531d1e90e856f60fc4b3afd708',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '74622',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'События. "События". Эфир от 22.05.2015 14:30',
|
2017-01-02 13:08:07 +01:00
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
2015-06-12 12:13:36 +02:00
|
|
|
|
'duration': 1122,
|
2015-06-07 16:25:30 +02:00
|
|
|
|
},
|
2015-06-12 12:13:36 +02:00
|
|
|
|
}
|
2015-06-07 16:25:30 +02:00
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2015-06-12 12:13:36 +02:00
|
|
|
|
video_id = self._match_id(url)
|
2015-06-07 16:25:30 +02:00
|
|
|
|
|
2015-06-12 12:13:36 +02:00
|
|
|
|
video = self._download_json(
|
|
|
|
|
'http://www.tvc.ru/video/json/id/%s' % video_id, video_id)
|
2015-06-07 16:25:30 +02:00
|
|
|
|
|
|
|
|
|
formats = []
|
2015-06-12 12:13:36 +02:00
|
|
|
|
for info in video.get('path', {}).get('quality', []):
|
|
|
|
|
video_url = info.get('url')
|
|
|
|
|
if not video_url:
|
|
|
|
|
continue
|
2015-06-07 16:25:30 +02:00
|
|
|
|
format_id = self._search_regex(
|
2015-06-12 12:13:36 +02:00
|
|
|
|
r'cdnvideo/([^/]+?)(?:-[^/]+?)?/', video_url,
|
|
|
|
|
'format id', default=None)
|
2015-06-07 16:25:30 +02:00
|
|
|
|
formats.append({
|
2015-06-12 12:13:36 +02:00
|
|
|
|
'url': video_url,
|
|
|
|
|
'format_id': format_id,
|
2015-06-07 16:25:30 +02:00
|
|
|
|
'width': int_or_none(info.get('width')),
|
|
|
|
|
'height': int_or_none(info.get('height')),
|
|
|
|
|
'tbr': int_or_none(info.get('bitrate')),
|
|
|
|
|
})
|
|
|
|
|
self._sort_formats(formats)
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
'id': video_id,
|
2015-06-12 12:13:36 +02:00
|
|
|
|
'title': video['title'],
|
|
|
|
|
'thumbnail': video.get('picture'),
|
|
|
|
|
'duration': int_or_none(video.get('duration')),
|
2015-06-07 16:25:30 +02:00
|
|
|
|
'formats': formats,
|
|
|
|
|
}
|
2015-06-12 12:13:36 +02:00
|
|
|
|
|
|
|
|
|
|
2015-06-12 12:24:13 +02:00
|
|
|
|
class TVCArticleIE(InfoExtractor):
|
2016-03-21 16:36:32 +01:00
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?tvc\.ru/(?!video/iframe/id/)(?P<id>[^?#]+)'
|
2015-06-12 12:13:36 +02:00
|
|
|
|
_TESTS = [{
|
|
|
|
|
'url': 'http://www.tvc.ru/channel/brand/id/29/show/episodes/episode_id/39702/',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '74622',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'События. "События". Эфир от 22.05.2015 14:30',
|
|
|
|
|
'description': 'md5:ad7aa7db22903f983e687b8a3e98c6dd',
|
2017-01-02 13:08:07 +01:00
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
2015-06-12 12:13:36 +02:00
|
|
|
|
'duration': 1122,
|
|
|
|
|
},
|
|
|
|
|
}, {
|
|
|
|
|
'url': 'http://www.tvc.ru/news/show/id/69944',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '75399',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Эксперты: в столице встал вопрос о максимально безопасных остановках',
|
|
|
|
|
'description': 'md5:f2098f71e21f309e89f69b525fd9846e',
|
2017-01-02 13:08:07 +01:00
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
2015-06-12 12:13:36 +02:00
|
|
|
|
'duration': 278,
|
|
|
|
|
},
|
|
|
|
|
}, {
|
|
|
|
|
'url': 'http://www.tvc.ru/channel/brand/id/47/show/episodes#',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '2185',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Ещё не поздно. Эфир от 03.08.2013',
|
|
|
|
|
'description': 'md5:51fae9f3f8cfe67abce014e428e5b027',
|
2017-01-02 13:08:07 +01:00
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
2015-06-12 12:13:36 +02:00
|
|
|
|
'duration': 3316,
|
|
|
|
|
},
|
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
|
webpage = self._download_webpage(url, self._match_id(url))
|
|
|
|
|
return {
|
|
|
|
|
'_type': 'url_transparent',
|
2015-06-12 12:25:26 +02:00
|
|
|
|
'ie_key': 'TVC',
|
2015-06-12 12:13:36 +02:00
|
|
|
|
'url': self._og_search_video_url(webpage),
|
|
|
|
|
'title': clean_html(self._og_search_title(webpage)),
|
|
|
|
|
'description': clean_html(self._og_search_description(webpage)),
|
|
|
|
|
'thumbnail': self._og_search_thumbnail(webpage),
|
|
|
|
|
}
|