mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-07-10 15:28:33 +00:00
[ie/volejtv] Fix extractor (#13203)
This commit is contained in:
parent
2685654a37
commit
71b4555a96
@ -1,40 +1,71 @@
|
|||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..utils import (
|
||||||
|
str_or_none,
|
||||||
|
strftime_or_none,
|
||||||
|
traverse_obj,
|
||||||
|
unified_timestamp,
|
||||||
|
url_or_none,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class VolejTVIE(InfoExtractor):
|
class VolejTVIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://volej\.tv/video/(?P<id>\d+)'
|
_VALID_URL = r'https?://volej\.tv/match/(?P<id>\d+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://volej.tv/video/725742/',
|
'url': 'https://volej.tv/match/270579',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '725742',
|
'id': '270579',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'description': 'Zápas VK Královo Pole vs VK Prostějov 10.12.2022 v 19:00 na Volej.TV',
|
'title': 'CZE-SWE (2024-06-16)',
|
||||||
'thumbnail': 'https://volej.tv/images/og/16/17186/og.png',
|
'categories': ['ženy'],
|
||||||
'title': 'VK Královo Pole vs VK Prostějov',
|
'series': 'ZLATÁ EVROPSKÁ VOLEJBALOVÁ LIGA',
|
||||||
|
'season': '2023-2024',
|
||||||
|
'timestamp': 1718553600,
|
||||||
|
'upload_date': '20240616',
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://volej.tv/video/725605/',
|
'url': 'https://volej.tv/match/487520',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '725605',
|
'id': '487520',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'thumbnail': 'https://volej.tv/images/og/15/17185/og.png',
|
'thumbnail': r're:https://.+\.(png|jpeg)',
|
||||||
'title': 'VK Lvi Praha vs VK Euro Sitex Příbram',
|
'title': 'CZE-FRA (2024-09-06)',
|
||||||
'description': 'Zápas VK Lvi Praha vs VK Euro Sitex Příbram 11.12.2022 v 19:00 na Volej.TV',
|
'categories': ['mládež'],
|
||||||
|
'series': 'Mistrovství Evropy do 20 let',
|
||||||
|
'season': '2024-2025',
|
||||||
|
'timestamp': 1725627600,
|
||||||
|
'upload_date': '20240906',
|
||||||
|
|
||||||
},
|
},
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, video_id)
|
json_data = self._download_json(f'https://api-volejtv-prod.apps.okd4.devopsie.cloud/api/match/{video_id}', video_id)
|
||||||
json_data = self._search_json(
|
formats = []
|
||||||
r'<\s*!\[CDATA[^=]+=', webpage, 'CDATA', video_id)
|
tbr_resolution_mapping = {'6000': '1080p', '2400': '720p', '1500': '480p', '800': '360p'}
|
||||||
formats, subtitle = self._extract_m3u8_formats_and_subtitles(
|
for video in traverse_obj(json_data, ('videos', 0, 'qualities')):
|
||||||
json_data['urls']['hls'], video_id)
|
formats.append({
|
||||||
return {
|
'url': video['cloud_front_path'],
|
||||||
|
'tbr': int(video['quality']),
|
||||||
|
'format_id': str(video['id']),
|
||||||
|
'format_note': tbr_resolution_mapping[video['quality']],
|
||||||
|
})
|
||||||
|
data = {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': self._html_search_meta(['og:title', 'twitter:title'], webpage),
|
**traverse_obj(json_data, {
|
||||||
'thumbnail': self._html_search_meta(['og:image', 'twitter:image'], webpage),
|
'series': ('competition_name', {str_or_none}),
|
||||||
'description': self._html_search_meta(['description', 'og:description', 'twitter:description'], webpage),
|
'season': ('season', {str_or_none}),
|
||||||
|
'timestamp': ('match_time', {unified_timestamp}),
|
||||||
|
'categories': ('category', ('title'), {str}, filter, all, filter),
|
||||||
|
'thumbnail': ('poster', {url_or_none}),
|
||||||
|
}),
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'subtitles': subtitle,
|
|
||||||
}
|
}
|
||||||
|
teams = list(set(traverse_obj(json_data, ('teams', ..., 'shortcut'))))
|
||||||
|
if len(teams) > 2 and 'FIN' in teams:
|
||||||
|
teams.remove('FIN')
|
||||||
|
title = '-'.join(sorted(teams))
|
||||||
|
if data.get('timestamp'):
|
||||||
|
title += f" ({strftime_or_none(data['timestamp'], '%Y-%m-%d')})"
|
||||||
|
data['title'] = title
|
||||||
|
return data
|
||||||
|
Loading…
Reference in New Issue
Block a user