2021-09-26 00:39:45 +02:00
|
|
|
from .common import InfoExtractor
|
|
|
|
from ..utils import (
|
|
|
|
int_or_none,
|
|
|
|
mimetype2ext,
|
2022-03-18 22:06:52 +01:00
|
|
|
str_or_none,
|
2021-09-26 00:39:45 +02:00
|
|
|
unified_timestamp,
|
|
|
|
url_or_none,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class VeoIE(InfoExtractor):
|
2022-03-17 22:31:00 +01:00
|
|
|
_VALID_URL = r'https?://app\.veo\.co/matches/(?P<id>[0-9A-Za-z-_]+)'
|
2021-09-26 00:39:45 +02:00
|
|
|
|
|
|
|
_TESTS = [{
|
|
|
|
'url': 'https://app.veo.co/matches/20201027-last-period/',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '20201027-last-period',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Akidemy u11s v Bradford Boys u11s (Game 3)',
|
|
|
|
'thumbnail': 're:https://c.veocdn.com/.+/thumbnail.jpg',
|
|
|
|
'upload_date': '20201028',
|
|
|
|
'timestamp': 1603847208,
|
|
|
|
'duration': 1916,
|
2022-03-18 22:06:52 +01:00
|
|
|
'view_count': int,
|
2024-06-12 01:09:58 +02:00
|
|
|
},
|
2022-03-17 22:31:00 +01:00
|
|
|
}, {
|
|
|
|
'url': 'https://app.veo.co/matches/20220313-2022-03-13_u15m-plsjq-vs-csl/',
|
|
|
|
'only_matching': True,
|
2021-09-26 00:39:45 +02:00
|
|
|
}]
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
|
|
|
|
metadata = self._download_json(
|
2024-06-12 01:09:58 +02:00
|
|
|
f'https://app.veo.co/api/app/matches/{video_id}', video_id)
|
2021-09-26 00:39:45 +02:00
|
|
|
|
|
|
|
video_data = self._download_json(
|
2024-06-12 01:09:58 +02:00
|
|
|
f'https://app.veo.co/api/app/matches/{video_id}/videos', video_id, 'Downloading video data')
|
2021-09-26 00:39:45 +02:00
|
|
|
|
|
|
|
formats = []
|
|
|
|
for fmt in video_data:
|
2022-03-18 22:06:52 +01:00
|
|
|
mimetype = str_or_none(fmt.get('mime_type'))
|
|
|
|
format_url = url_or_none(fmt.get('url'))
|
2021-09-26 00:39:45 +02:00
|
|
|
# skip configuration file for panoramic video
|
2022-03-18 22:06:52 +01:00
|
|
|
if not format_url or mimetype == 'video/mp2t':
|
2021-09-26 00:39:45 +02:00
|
|
|
continue
|
2022-03-18 22:06:52 +01:00
|
|
|
|
2021-09-26 00:39:45 +02:00
|
|
|
height = int_or_none(fmt.get('height'))
|
2022-03-18 22:06:52 +01:00
|
|
|
render_type = str_or_none(fmt.get('render_type'))
|
|
|
|
format_id = f'{render_type}-{height}p' if render_type and height else None
|
|
|
|
|
|
|
|
# Veo returns panoramic video information even if panoramic video is not available.
|
|
|
|
# e.g. https://app.veo.co/matches/20201027-last-period/
|
|
|
|
if render_type == 'panorama':
|
|
|
|
if not self._is_valid_url(format_url, video_id, format_id):
|
|
|
|
continue
|
|
|
|
|
2021-09-26 00:39:45 +02:00
|
|
|
formats.append({
|
2022-03-18 22:06:52 +01:00
|
|
|
'url': format_url,
|
|
|
|
'format_id': format_id,
|
2021-09-26 00:39:45 +02:00
|
|
|
'ext': mimetype2ext(mimetype),
|
|
|
|
'width': int_or_none(fmt.get('width')),
|
|
|
|
'height': height,
|
2022-03-18 22:06:52 +01:00
|
|
|
'vbr': int_or_none(fmt.get('bit_rate'), scale=1000),
|
2021-09-26 00:39:45 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
2022-03-18 22:06:52 +01:00
|
|
|
'title': str_or_none(metadata.get('title')),
|
2021-09-26 00:39:45 +02:00
|
|
|
'formats': formats,
|
2022-03-18 22:06:52 +01:00
|
|
|
'thumbnail': url_or_none(metadata.get('thumbnail')),
|
|
|
|
'timestamp': unified_timestamp(metadata.get('created')),
|
|
|
|
'view_count': int_or_none(metadata.get('view_count')),
|
|
|
|
'duration': int_or_none(metadata.get('duration')),
|
2021-09-26 00:39:45 +02:00
|
|
|
}
|