1 from .common
import InfoExtractor
11 class CaffeineTVIE(InfoExtractor
):
12 _VALID_URL
= r
'https?://(?:www\.)?caffeine\.tv/[^/?#]+/video/(?P<id>[\da-f-]+)'
14 'url': 'https://www.caffeine.tv/TsuSurf/video/cffc0a00-e73f-11ec-8080-80017d29f26e',
16 'id': 'cffc0a00-e73f-11ec-8080-80017d29f26e',
18 'title': 'GOOOOD MORNINNNNN #highlights',
19 'timestamp': 1654702180,
20 'upload_date': '20220608',
21 'uploader': 'RahJON Wicc',
22 'uploader_id': 'TsuSurf',
25 'thumbnail': 'https://www.caffeine.tv/broadcasts/776b6f84-9cd5-42e3-af1d-4a776eeed697/replay/lobby.jpg',
29 'tags': ['highlights', 'battlerap'],
32 'skip_download': 'm3u8',
36 def _real_extract(self
, url
):
37 video_id
= self
._match
_id
(url
)
38 json_data
= self
._download
_json
(
39 f
'https://api.caffeine.tv/social/public/activity/{video_id}', video_id
)
40 broadcast_info
= traverse_obj(json_data
, ('broadcast_info', {dict}
)) or {}
42 video_url
= broadcast_info
['video_url']
43 ext
= determine_ext(video_url
)
45 formats
= self
._extract
_m
3u8_formats
(video_url
, video_id
, 'mp4')
47 formats
= [{'url': video_url
}]
52 **traverse_obj(json_data
, {
53 'like_count': ('like_count', {int_or_none}
),
54 'view_count': ('view_count', {int_or_none}
),
55 'comment_count': ('comment_count', {int_or_none}
),
56 'tags': ('tags', ..., {str}
, filter),
57 'uploader': ('user', 'name', {str}
),
58 'uploader_id': (((None, 'user'), 'username'), {str}
, any
),
59 'is_live': ('is_live', {bool}
),
61 **traverse_obj(broadcast_info
, {
62 'title': ('broadcast_title', {str}
),
63 'duration': ('content_duration', {int_or_none}
),
64 'timestamp': ('broadcast_start_time', {parse_iso8601}
),
65 'thumbnail': ('preview_image_path', {urljoin(url
)}),
68 # assume Apple Store ratings: https://en.wikipedia.org/wiki/Mobile_software_content_rating_system
73 }.get(broadcast_info
.get('content_rating'), 17),