5 from .common
import InfoExtractor
16 class MildomBaseIE(InfoExtractor
):
19 def _call_api(self
, url
, video_id
, query
=None, note
='Downloading JSON metadata', body
=None):
20 if not self
._GUEST
_ID
:
21 self
._GUEST
_ID
= f
'pc-gp-{uuid.uuid4()}'
23 content
= self
._download
_json
(
24 url
, video_id
, note
=note
, data
=json
.dumps(body
).encode() if body
else None,
25 headers
={'Content-Type': 'application/json'} if body
else {},
27 '__guest_id': self
._GUEST
_ID
,
32 if content
['code'] != 0:
34 f
'Mildom says: {content["message"]} (code {content["code"]})',
36 return content
['body']
39 class MildomIE(MildomBaseIE
):
41 IE_DESC
= 'Record ongoing live by specific user in Mildom'
42 _VALID_URL
= r
'https?://(?:(?:www|m)\.)mildom\.com/(?P<id>\d+)'
44 def _real_extract(self
, url
):
45 video_id
= self
._match
_id
(url
)
46 webpage
= self
._download
_webpage
(f
'https://www.mildom.com/{video_id}', video_id
)
48 enterstudio
= self
._call
_api
(
49 'https://cloudac.mildom.com/nonolive/gappserv/live/enterstudio', video_id
,
50 note
='Downloading live metadata', query
={'user_id': video_id
})
51 result_video_id
= enterstudio
.get('log_id', video_id
)
53 servers
= self
._call
_api
(
54 'https://cloudac.mildom.com/nonolive/gappserv/live/liveserver', result_video_id
,
55 note
='Downloading live server list', query
={
57 'live_server_type': 'hls',
60 playback_token
= self
._call
_api
(
61 'https://cloudac.mildom.com/nonolive/gappserv/live/token', result_video_id
,
62 note
='Obtaining live playback token', body
={'host_id': video_id
, 'type': 'hls'})
63 playback_token
= traverse_obj(playback_token
, ('data', ..., 'token'), get_all
=False)
64 if not playback_token
:
65 raise ExtractorError('Failed to obtain live playback token')
67 formats
= self
._extract
_m
3u8_formats
(
68 f
'{servers["stream_server"]}/{video_id}_master.m3u8?{playback_token}',
69 result_video_id
, 'mp4', headers
={
70 'Referer': 'https://www.mildom.com/',
71 'Origin': 'https://www.mildom.com',
75 fmt
.setdefault('http_headers', {})['Referer'] = 'https://www.mildom.com/'
78 'id': result_video_id
,
79 'title': self
._html
_search
_meta
('twitter:description', webpage
, default
=None) or traverse_obj(enterstudio
, 'anchor_intro'),
80 'description': traverse_obj(enterstudio
, 'intro', 'live_intro', expected_type
=str),
81 'timestamp': float_or_none(enterstudio
.get('live_start_ms'), scale
=1000),
82 'uploader': self
._html
_search
_meta
('twitter:title', webpage
, default
=None) or traverse_obj(enterstudio
, 'loginname'),
83 'uploader_id': video_id
,
89 class MildomVodIE(MildomBaseIE
):
90 IE_NAME
= 'mildom:vod'
91 IE_DESC
= 'VOD in Mildom'
92 _VALID_URL
= r
'https?://(?:(?:www|m)\.)mildom\.com/playback/(?P<user_id>\d+)/(?P<id>(?P=user_id)-[a-zA-Z0-9]+-?[0-9]*)'
94 'url': 'https://www.mildom.com/playback/10882672/10882672-1597662269',
96 'id': '10882672-1597662269',
98 'title': '始めてのミルダム配信じゃぃ!',
99 'thumbnail': r
're:^https?://.*\.(png|jpg)$',
100 'upload_date': '20200817',
102 'description': 'ゲームをしたくて!',
103 'timestamp': 1597662269.0,
104 'uploader_id': '10882672',
105 'uploader': 'kson組長(けいそん)',
108 'url': 'https://www.mildom.com/playback/10882672/10882672-1597758589870-477',
110 'id': '10882672-1597758589870-477',
112 'title': '【kson】感染メイズ!麻酔銃で無双する',
113 'thumbnail': r
're:^https?://.*\.(png|jpg)$',
114 'timestamp': 1597759093.0,
115 'uploader': 'kson組長(けいそん)',
117 'uploader_id': '10882672',
118 'description': 'このステージ絶対乗り越えたい',
119 'upload_date': '20200818',
122 'url': 'https://www.mildom.com/playback/10882672/10882672-buha9td2lrn97fk2jme0',
124 'id': '10882672-buha9td2lrn97fk2jme0',
126 'title': '【kson組長】CART RACER!!!',
127 'thumbnail': r
're:^https?://.*\.(png|jpg)$',
128 'uploader_id': '10882672',
129 'uploader': 'kson組長(けいそん)',
130 'upload_date': '20201104',
131 'timestamp': 1604494797.0,
133 'description': 'WTF',
137 def _real_extract(self
, url
):
138 user_id
, video_id
= self
._match
_valid
_url
(url
).group('user_id', 'id')
139 webpage
= self
._download
_webpage
(f
'https://www.mildom.com/playback/{user_id}/{video_id}', video_id
)
141 autoplay
= self
._call
_api
(
142 'https://cloudac.mildom.com/nonolive/videocontent/playback/getPlaybackDetail', video_id
,
143 note
='Downloading playback metadata', query
={
148 'url': autoplay
['audio_url'],
149 'format_id': 'audio',
150 'protocol': 'm3u8_native',
155 for fmt
in autoplay
['video_link']:
157 'format_id': 'video-{}'.format(fmt
['name']),
159 'protocol': 'm3u8_native',
160 'width': fmt
['level'] * autoplay
['video_width'] // autoplay
['video_height'],
161 'height': fmt
['level'],
169 'title': self
._html
_search
_meta
(('og:description', 'description'), webpage
, default
=None) or autoplay
.get('title'),
170 'description': traverse_obj(autoplay
, 'video_intro'),
171 'timestamp': float_or_none(autoplay
.get('publish_time'), scale
=1000),
172 'duration': float_or_none(autoplay
.get('video_length'), scale
=1000),
173 'thumbnail': dict_get(autoplay
, ('upload_pic', 'video_pic')),
174 'uploader': traverse_obj(autoplay
, ('author_info', 'login_name')),
175 'uploader_id': user_id
,
180 class MildomClipIE(MildomBaseIE
):
181 IE_NAME
= 'mildom:clip'
182 IE_DESC
= 'Clip in Mildom'
183 _VALID_URL
= r
'https?://(?:(?:www|m)\.)mildom\.com/clip/(?P<id>(?P<user_id>\d+)-[a-zA-Z0-9]+)'
185 'url': 'https://www.mildom.com/clip/10042245-63921673e7b147ebb0806d42b5ba5ce9',
187 'id': '10042245-63921673e7b147ebb0806d42b5ba5ce9',
189 'timestamp': 1619181890,
191 'thumbnail': r
're:https?://.+',
193 'uploader_id': '10042245',
196 'url': 'https://www.mildom.com/clip/10111524-ebf4036e5aa8411c99fb3a1ae0902864',
198 'id': '10111524-ebf4036e5aa8411c99fb3a1ae0902864',
200 'timestamp': 1621094003,
202 'thumbnail': r
're:https?://.+',
204 'uploader_id': '10111524',
207 'url': 'https://www.mildom.com/clip/10660174-2c539e6e277c4aaeb4b1fbe8d22cb902',
209 'id': '10660174-2c539e6e277c4aaeb4b1fbe8d22cb902',
211 'timestamp': 1614769431,
213 'thumbnail': r
're:https?://.+',
214 'uploader': 'ドルゴルスレンギーン=ダグワドルジ',
215 'uploader_id': '10660174',
219 def _real_extract(self
, url
):
220 user_id
, video_id
= self
._match
_valid
_url
(url
).group('user_id', 'id')
221 webpage
= self
._download
_webpage
(f
'https://www.mildom.com/clip/{video_id}', video_id
)
223 clip_detail
= self
._call
_api
(
224 'https://cloudac-cf-jp.mildom.com/nonolive/videocontent/clip/detail', video_id
,
225 note
='Downloading playback metadata', query
={
231 'title': self
._html
_search
_meta
(
232 ('og:description', 'description'), webpage
, default
=None) or clip_detail
.get('title'),
233 'timestamp': float_or_none(clip_detail
.get('create_time')),
234 'duration': float_or_none(clip_detail
.get('length')),
235 'thumbnail': clip_detail
.get('cover'),
236 'uploader': traverse_obj(clip_detail
, ('user_info', 'loginname')),
237 'uploader_id': user_id
,
239 'url': clip_detail
['url'],
240 'ext': determine_ext(clip_detail
.get('url'), 'mp4'),
244 class MildomUserVodIE(MildomBaseIE
):
245 IE_NAME
= 'mildom:user:vod'
246 IE_DESC
= 'Download all VODs from specific user in Mildom'
247 _VALID_URL
= r
'https?://(?:(?:www|m)\.)mildom\.com/profile/(?P<id>\d+)'
249 'url': 'https://www.mildom.com/profile/10093333',
252 'title': 'Uploads from ねこばたけ',
254 'playlist_mincount': 732,
256 'url': 'https://www.mildom.com/profile/10882672',
259 'title': 'Uploads from kson組長(けいそん)',
261 'playlist_mincount': 201,
264 def _fetch_page(self
, user_id
, page
):
266 reply
= self
._call
_api
(
267 'https://cloudac.mildom.com/nonolive/videocontent/profile/playbackList',
268 user_id
, note
=f
'Downloading page {page}', query
={
279 yield self
.url_result(f
'https://www.mildom.com/playback/{user_id}/{v_id}')
281 def _real_extract(self
, url
):
282 user_id
= self
._match
_id
(url
)
283 self
.to_screen(f
'This will download all VODs belonging to user. To download ongoing live video, use "https://www.mildom.com/{user_id}" instead')
285 profile
= self
._call
_api
(
286 'https://cloudac.mildom.com/nonolive/gappserv/user/profileV2', user_id
,
287 query
={'user_id': user_id
}, note
='Downloading user profile')['user_info']
289 return self
.playlist_result(
290 OnDemandPagedList(functools
.partial(self
._fetch
_page
, user_id
), 30),
291 user_id
, f
'Uploads from {profile["loginname"]}')