2015-03-08 06:03:12 -06:00
|
|
|
from .common import InfoExtractor
|
|
|
|
from ..utils import (
|
|
|
|
ExtractorError,
|
2024-05-26 13:27:21 -06:00
|
|
|
determine_ext,
|
2015-03-08 06:03:12 -06:00
|
|
|
int_or_none,
|
2021-08-22 13:02:00 -06:00
|
|
|
parse_qs,
|
2015-03-08 06:09:47 -06:00
|
|
|
qualities,
|
2024-05-26 13:27:21 -06:00
|
|
|
xpath_text,
|
2015-03-08 06:03:12 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class PladformIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'''(?x)
|
|
|
|
https?://
|
|
|
|
(?:
|
|
|
|
(?:
|
|
|
|
out\.pladform\.ru/player|
|
|
|
|
static\.pladform\.ru/player\.swf
|
|
|
|
)
|
|
|
|
\?.*\bvideoid=|
|
|
|
|
video\.pladform\.ru/catalog/video/videoid/
|
|
|
|
)
|
|
|
|
(?P<id>\d+)
|
|
|
|
'''
|
2022-07-31 19:23:25 -06:00
|
|
|
_EMBED_REGEX = [r'<iframe[^>]+src=(["\'])(?P<url>(?:https?:)?//out\.pladform\.ru/player\?.+?)\1']
|
2015-03-08 06:03:12 -06:00
|
|
|
_TESTS = [{
|
2022-01-31 16:53:54 -07:00
|
|
|
'url': 'http://out.pladform.ru/player?pl=18079&type=html5&videoid=100231282',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '6216d548e755edae6e8280667d774791',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'timestamp': 1406117012,
|
|
|
|
'title': 'Гарик Мартиросян и Гарик Харламов - Кастинг на концерт ко Дню милиции',
|
|
|
|
'age_limit': 0,
|
|
|
|
'upload_date': '20140723',
|
|
|
|
'thumbnail': str,
|
|
|
|
'view_count': int,
|
|
|
|
'description': str,
|
|
|
|
'uploader_id': '12082',
|
|
|
|
'uploader': 'Comedy Club',
|
|
|
|
'duration': 367,
|
|
|
|
},
|
2024-06-11 17:09:58 -06:00
|
|
|
'expected_warnings': ['HTTP Error 404: Not Found'],
|
2022-01-31 16:53:54 -07:00
|
|
|
}, {
|
2018-02-01 13:07:30 -07:00
|
|
|
'url': 'https://out.pladform.ru/player?pl=64471&videoid=3777899&vk_puid15=0&vk_puid34=0',
|
|
|
|
'md5': '53362fac3a27352da20fa2803cc5cd6f',
|
2015-03-08 06:03:12 -06:00
|
|
|
'info_dict': {
|
2018-02-01 13:07:30 -07:00
|
|
|
'id': '3777899',
|
2015-03-08 06:03:12 -06:00
|
|
|
'ext': 'mp4',
|
2018-02-01 13:07:30 -07:00
|
|
|
'title': 'СТУДИЯ СОЮЗ • Шоу Студия Союз, 24 выпуск (01.02.2018) Нурлан Сабуров и Слава Комиссаренко',
|
|
|
|
'description': 'md5:05140e8bf1b7e2d46e7ba140be57fd95',
|
2017-01-02 05:08:07 -07:00
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
2018-02-01 13:07:30 -07:00
|
|
|
'duration': 3190,
|
2015-03-08 06:03:12 -06:00
|
|
|
},
|
|
|
|
}, {
|
|
|
|
'url': 'http://static.pladform.ru/player.swf?pl=21469&videoid=100183293&vkcid=0',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'http://video.pladform.ru/catalog/video/videoid/100183293/vkcid/0',
|
|
|
|
'only_matching': True,
|
|
|
|
}]
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
|
2021-08-22 13:02:00 -06:00
|
|
|
qs = parse_qs(url)
|
2018-02-01 13:07:30 -07:00
|
|
|
pl = qs.get('pl', ['1'])[0]
|
|
|
|
|
2015-03-08 06:03:12 -06:00
|
|
|
video = self._download_xml(
|
2018-02-01 13:07:30 -07:00
|
|
|
'http://out.pladform.ru/getVideo', video_id, query={
|
|
|
|
'pl': pl,
|
|
|
|
'videoid': video_id,
|
2022-01-31 16:53:54 -07:00
|
|
|
}, fatal=False)
|
2015-03-08 06:03:12 -06:00
|
|
|
|
2018-02-01 13:07:30 -07:00
|
|
|
def fail(text):
|
2015-03-08 06:03:12 -06:00
|
|
|
raise ExtractorError(
|
2024-06-11 17:09:58 -06:00
|
|
|
f'{self.IE_NAME} returned error: {text}',
|
2015-03-08 06:03:12 -06:00
|
|
|
expected=True)
|
|
|
|
|
2022-01-31 16:53:54 -07:00
|
|
|
if not video:
|
2024-06-11 17:09:58 -06:00
|
|
|
target_url = self._request_webpage(url, video_id, note='Resolving final URL').url
|
|
|
|
if target_url == url:
|
2022-01-31 16:53:54 -07:00
|
|
|
raise ExtractorError('Can\'t parse page')
|
2024-06-11 17:09:58 -06:00
|
|
|
return self.url_result(target_url)
|
2022-01-31 16:53:54 -07:00
|
|
|
|
2018-02-01 13:07:30 -07:00
|
|
|
if video.tag == 'error':
|
|
|
|
fail(video.text)
|
|
|
|
|
2015-03-08 06:09:47 -06:00
|
|
|
quality = qualities(('ld', 'sd', 'hd'))
|
|
|
|
|
2018-02-01 13:07:30 -07:00
|
|
|
formats = []
|
|
|
|
for src in video.findall('./src'):
|
|
|
|
if src is None:
|
|
|
|
continue
|
|
|
|
format_url = src.text
|
|
|
|
if not format_url:
|
|
|
|
continue
|
|
|
|
if src.get('type') == 'hls' or determine_ext(format_url) == 'm3u8':
|
|
|
|
formats.extend(self._extract_m3u8_formats(
|
|
|
|
format_url, video_id, 'mp4', entry_protocol='m3u8_native',
|
|
|
|
m3u8_id='hls', fatal=False))
|
|
|
|
else:
|
|
|
|
formats.append({
|
|
|
|
'url': src.text,
|
|
|
|
'format_id': src.get('quality'),
|
|
|
|
'quality': quality(src.get('quality')),
|
|
|
|
})
|
|
|
|
|
|
|
|
if not formats:
|
|
|
|
error = xpath_text(video, './cap', 'error', default=None)
|
|
|
|
if error:
|
|
|
|
fail(error)
|
|
|
|
|
2015-03-08 06:03:12 -06:00
|
|
|
webpage = self._download_webpage(
|
2024-06-11 17:09:58 -06:00
|
|
|
f'http://video.pladform.ru/catalog/video/videoid/{video_id}',
|
2015-03-08 06:03:12 -06:00
|
|
|
video_id)
|
|
|
|
|
|
|
|
title = self._og_search_title(webpage, fatal=False) or xpath_text(
|
|
|
|
video, './/title', 'title', fatal=True)
|
|
|
|
description = self._search_regex(
|
|
|
|
r'</h3>\s*<p>([^<]+)</p>', webpage, 'description', fatal=False)
|
|
|
|
thumbnail = self._og_search_thumbnail(webpage) or xpath_text(
|
|
|
|
video, './/cover', 'cover')
|
|
|
|
|
|
|
|
duration = int_or_none(xpath_text(video, './/time', 'duration'))
|
|
|
|
age_limit = int_or_none(xpath_text(video, './/age18', 'age limit'))
|
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'title': title,
|
|
|
|
'description': description,
|
|
|
|
'thumbnail': thumbnail,
|
|
|
|
'duration': duration,
|
|
|
|
'age_limit': age_limit,
|
|
|
|
'formats': formats,
|
|
|
|
}
|