12
12
update_url_query ,
13
13
random_uuidv4 ,
14
14
try_get ,
15
+ float_or_none ,
16
+ dict_get
15
17
)
16
18
from ..compat import (
17
19
compat_str ,
@@ -22,9 +24,18 @@ class MildomBaseIE(InfoExtractor):
22
24
_GUEST_ID = None
23
25
_DISPATCHER_CONFIG = None
24
26
25
- def _call_api (self , url , video_id , query = {}, note = 'Downloading JSON metadata' , init = False ):
27
+ def _call_api (self , url , video_id , query = None , note = 'Downloading JSON metadata' , init = False ):
28
+ query = query or {}
29
+ if query :
30
+ query ['__platform' ] = 'web'
26
31
url = update_url_query (url , self ._common_queries (query , init = init ))
27
- return self ._download_json (url , video_id , note = note )['body' ]
32
+ content = self ._download_json (url , video_id , note = note )
33
+ if content ['code' ] == 0 :
34
+ return content ['body' ]
35
+ else :
36
+ self .raise_no_formats (
37
+ f'Video not found or premium content. { content ["code" ]} - { content ["message" ]} ' ,
38
+ expected = True )
28
39
29
40
def _common_queries (self , query = {}, init = False ):
30
41
dc = self ._fetch_dispatcher_config ()
@@ -148,6 +159,7 @@ def _real_extract(self, url):
148
159
'id' : result_video_id ,
149
160
'title' : title ,
150
161
'description' : description ,
162
+ 'timestamp' : float_or_none (enterstudio .get ('live_start_ms' ), scale = 1000 ),
151
163
'uploader' : uploader ,
152
164
'uploader_id' : video_id ,
153
165
'formats' : formats ,
@@ -158,7 +170,50 @@ def _real_extract(self, url):
158
170
class MildomVodIE (MildomBaseIE ):
159
171
IE_NAME = 'mildom:vod'
160
172
IE_DESC = 'Download a VOD in Mildom'
161
- _VALID_URL = r'https?://(?:(?:www|m)\.)mildom\.com/playback/(?P<user_id>\d+)/(?P<id>(?P=user_id)-[a-zA-Z0-9]+)'
173
+ _VALID_URL = r'https?://(?:(?:www|m)\.)mildom\.com/playback/(?P<user_id>\d+)/(?P<id>(?P=user_id)-[a-zA-Z0-9]+-?[0-9]*)'
174
+ _TESTS = [{
175
+ 'url' : 'https://www.mildom.com/playback/10882672/10882672-1597662269' ,
176
+ 'info_dict' : {
177
+ 'id' : '10882672-1597662269' ,
178
+ 'ext' : 'mp4' ,
179
+ 'title' : '始めてのミルダム配信じゃぃ!' ,
180
+ 'thumbnail' : r're:^https?://.*\.(png|jpg)$' ,
181
+ 'upload_date' : '20200817' ,
182
+ 'duration' : 4138.37 ,
183
+ 'description' : 'ゲームをしたくて!' ,
184
+ 'timestamp' : 1597662269.0 ,
185
+ 'uploader_id' : '10882672' ,
186
+ 'uploader' : 'kson組長(けいそん)' ,
187
+ },
188
+ }, {
189
+ 'url' : 'https://www.mildom.com/playback/10882672/10882672-1597758589870-477' ,
190
+ 'info_dict' : {
191
+ 'id' : '10882672-1597758589870-477' ,
192
+ 'ext' : 'mp4' ,
193
+ 'title' : '【kson】感染メイズ!麻酔銃で無双する' ,
194
+ 'thumbnail' : r're:^https?://.*\.(png|jpg)$' ,
195
+ 'timestamp' : 1597759093.0 ,
196
+ 'uploader' : 'kson組長(けいそん)' ,
197
+ 'duration' : 4302.58 ,
198
+ 'uploader_id' : '10882672' ,
199
+ 'description' : 'このステージ絶対乗り越えたい' ,
200
+ 'upload_date' : '20200818' ,
201
+ },
202
+ }, {
203
+ 'url' : 'https://www.mildom.com/playback/10882672/10882672-buha9td2lrn97fk2jme0' ,
204
+ 'info_dict' : {
205
+ 'id' : '10882672-buha9td2lrn97fk2jme0' ,
206
+ 'ext' : 'mp4' ,
207
+ 'title' : '【kson組長】CART RACER!!!' ,
208
+ 'thumbnail' : r're:^https?://.*\.(png|jpg)$' ,
209
+ 'uploader_id' : '10882672' ,
210
+ 'uploader' : 'kson組長(けいそん)' ,
211
+ 'upload_date' : '20201104' ,
212
+ 'timestamp' : 1604494797.0 ,
213
+ 'duration' : 4657.25 ,
214
+ 'description' : 'WTF' ,
215
+ },
216
+ }]
162
217
163
218
def _real_extract (self , url ):
164
219
m = self ._match_valid_url (url )
@@ -213,6 +268,9 @@ def _real_extract(self, url):
213
268
'id' : video_id ,
214
269
'title' : title ,
215
270
'description' : description ,
271
+ 'timestamp' : float_or_none (autoplay ['publish_time' ], scale = 1000 ),
272
+ 'duration' : float_or_none (autoplay ['video_length' ], scale = 1000 ),
273
+ 'thumbnail' : dict_get (autoplay , ('upload_pic' , 'video_pic' )),
216
274
'uploader' : uploader ,
217
275
'uploader_id' : user_id ,
218
276
'formats' : formats ,
@@ -230,6 +288,13 @@ class MildomUserVodIE(MildomBaseIE):
230
288
'title' : 'Uploads from ねこばたけ' ,
231
289
},
232
290
'playlist_mincount' : 351 ,
291
+ }, {
292
+ 'url' : 'https://www.mildom.com/profile/10882672' ,
293
+ 'info_dict' : {
294
+ 'id' : '10882672' ,
295
+ 'title' : 'Uploads from kson組長(けいそん)' ,
296
+ },
297
+ 'playlist_mincount' : 191 ,
233
298
}]
234
299
235
300
def _entries (self , user_id ):
0 commit comments