]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/openrec.py
d7073ab445bc4cd537a980d7083c5a1a17620de1
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
11 from ..compat
import compat_str
14 class OpenRecIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://(?:www\.)?openrec\.tv/live/(?P<id>[^/]+)'
18 'url': 'https://www.openrec.tv/live/2p8v31qe4zy',
19 'only_matching': True,
21 'url': 'https://www.openrec.tv/live/wez93eqvjzl',
22 'only_matching': True,
25 def _real_extract(self
, url
):
26 video_id
= self
._match
_id
(url
)
27 webpage
= self
._download
_webpage
('https://www.openrec.tv/live/%s' % video_id
, video_id
)
29 window_stores
= self
._parse
_json
(
30 self
._search
_regex
(r
'(?m)window\.pageStore\s*=\s*(\{.+?\});$', webpage
, 'window.pageStore'), video_id
)
31 movie_store
= traverse_obj(
33 ('v8', 'state', 'movie'),
37 raise ExtractorError('Failed to extract live info')
39 title
= movie_store
.get('title')
40 description
= movie_store
.get('introduction')
41 thumbnail
= movie_store
.get('thumbnailUrl')
43 channel_user
= movie_store
.get('channel', {}).get('user')
44 uploader
= try_get(channel_user
, lambda x
: x
['name'], compat_str
)
45 uploader_id
= try_get(channel_user
, lambda x
: x
['id'], compat_str
)
47 timestamp
= traverse_obj(movie_store
, ('startedAt', 'time'), expected_type
=int)
49 m3u8_playlists
= movie_store
.get('media')
51 for (name
, m3u8_url
) in m3u8_playlists
.items():
54 formats
.extend(self
._extract
_m
3u8_formats
(
55 m3u8_url
, video_id
, ext
='mp4', entry_protocol
='m3u8',
56 m3u8_id
='hls-%s' % name
, live
=True))
58 self
._sort
_formats
(formats
)
63 'description': description
,
64 'thumbnail': thumbnail
,
67 'uploader_id': uploader_id
,
68 'timestamp': timestamp
,
73 class OpenRecCaptureIE(InfoExtractor
):
74 IE_NAME
= 'openrec:capture'
75 _VALID_URL
= r
'https?://(?:www\.)?openrec\.tv/capture/(?P<id>[^/]+)'
77 'url': 'https://www.openrec.tv/capture/l9nk2x4gn14',
78 'only_matching': True,
80 'url': 'https://www.openrec.tv/capture/mldjr82p7qk',
83 'title': 'たいじの恥ずかしい英語力',
84 'uploader': 'たいちゃんねる',
85 'uploader_id': 'Yaritaiji',
86 'upload_date': '20210803',
90 def _real_extract(self
, url
):
91 video_id
= self
._match
_id
(url
)
92 webpage
= self
._download
_webpage
('https://www.openrec.tv/capture/%s' % video_id
, video_id
)
94 window_stores
= self
._parse
_json
(
95 self
._search
_regex
(r
'(?m)window\.pageStore\s*=\s*(\{.+?\});$', webpage
, 'window.pageStore'), video_id
)
96 movie_store
= window_stores
.get('movie')
98 capture_data
= window_stores
.get('capture')
100 raise ExtractorError('Cannot extract title')
101 title
= capture_data
.get('title')
102 thumbnail
= capture_data
.get('thumbnailUrl')
103 upload_date
= unified_strdate(capture_data
.get('createdAt'))
105 channel_info
= movie_store
.get('channel') or {}
106 uploader
= channel_info
.get('name')
107 uploader_id
= channel_info
.get('id')
109 m3u8_url
= capture_data
.get('source')
111 raise ExtractorError('Cannot extract m3u8 url')
112 formats
= self
._extract
_m
3u8_formats
(
113 m3u8_url
, video_id
, ext
='mp4', entry_protocol
='m3u8_native',
116 self
._sort
_formats
(formats
)
121 'thumbnail': thumbnail
,
123 'uploader': uploader
,
124 'uploader_id': uploader_id
,
125 'upload_date': upload_date
,