]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/veo.py
[youtube:comments] Add more options for limiting number of comments extracted (#1626)
[yt-dlp.git] / yt_dlp / extractor / veo.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6 from ..utils import (
7 int_or_none,
8 mimetype2ext,
9 unified_timestamp,
10 url_or_none,
11 )
12
13
14 class VeoIE(InfoExtractor):
15 _VALID_URL = r'https?://app\.veo\.co/matches/(?P<id>[0-9A-Za-z-]+)'
16
17 _TESTS = [{
18 'url': 'https://app.veo.co/matches/20201027-last-period/',
19 'info_dict': {
20 'id': '20201027-last-period',
21 'ext': 'mp4',
22 'title': 'Akidemy u11s v Bradford Boys u11s (Game 3)',
23 'thumbnail': 're:https://c.veocdn.com/.+/thumbnail.jpg',
24 'upload_date': '20201028',
25 'timestamp': 1603847208,
26 'duration': 1916,
27 }
28 }]
29
30 def _real_extract(self, url):
31 video_id = self._match_id(url)
32
33 metadata = self._download_json(
34 'https://app.veo.co/api/app/matches/%s' % video_id, video_id)
35
36 video_data = self._download_json(
37 'https://app.veo.co/api/app/matches/%s/videos' % video_id, video_id, 'Downloading video data')
38
39 title = metadata.get('title')
40 thumbnail = url_or_none(metadata.get('thumbnail'))
41
42 timestamp = unified_timestamp(metadata.get('created'))
43 duration = int_or_none(metadata.get('duration'))
44 view_count = int_or_none(metadata.get('view_count'))
45
46 formats = []
47 for fmt in video_data:
48 mimetype = fmt.get('mime_type')
49 # skip configuration file for panoramic video
50 if mimetype == 'video/mp2t':
51 continue
52 height = int_or_none(fmt.get('height'))
53 bitrate = int_or_none(fmt.get('bit_rate'), scale=1000)
54 render_type = fmt.get('render_type')
55 formats.append({
56 'url': url_or_none(fmt.get('url')),
57 'format_id': '%s-%sp' % (render_type, height),
58 'ext': mimetype2ext(mimetype),
59 'width': int_or_none(fmt.get('width')),
60 'height': height,
61 'vbr': bitrate
62 })
63
64 self._sort_formats(formats)
65
66 return {
67 'id': video_id,
68 'title': title,
69 'formats': formats,
70 'thumbnail': thumbnail,
71 'timestamp': timestamp,
72 'view_count': view_count,
73 'duration': duration
74 }