Skip to content

Commit 63bac93

Browse files
authored
[mildom] Fix extractor (yt-dlp#2533)
Closes yt-dlp#2519 Authored by: lazypete365
1 parent 7c74a01 commit 63bac93

File tree

1 file changed

+68
-3
lines changed

1 file changed

+68
-3
lines changed

yt_dlp/extractor/mildom.py

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
update_url_query,
1313
random_uuidv4,
1414
try_get,
15+
float_or_none,
16+
dict_get
1517
)
1618
from ..compat import (
1719
compat_str,
@@ -22,9 +24,18 @@ class MildomBaseIE(InfoExtractor):
2224
_GUEST_ID = None
2325
_DISPATCHER_CONFIG = None
2426

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'
2631
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)
2839

2940
def _common_queries(self, query={}, init=False):
3041
dc = self._fetch_dispatcher_config()
@@ -148,6 +159,7 @@ def _real_extract(self, url):
148159
'id': result_video_id,
149160
'title': title,
150161
'description': description,
162+
'timestamp': float_or_none(enterstudio.get('live_start_ms'), scale=1000),
151163
'uploader': uploader,
152164
'uploader_id': video_id,
153165
'formats': formats,
@@ -158,7 +170,50 @@ def _real_extract(self, url):
158170
class MildomVodIE(MildomBaseIE):
159171
IE_NAME = 'mildom:vod'
160172
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+
}]
162217

163218
def _real_extract(self, url):
164219
m = self._match_valid_url(url)
@@ -213,6 +268,9 @@ def _real_extract(self, url):
213268
'id': video_id,
214269
'title': title,
215270
'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')),
216274
'uploader': uploader,
217275
'uploader_id': user_id,
218276
'formats': formats,
@@ -230,6 +288,13 @@ class MildomUserVodIE(MildomBaseIE):
230288
'title': 'Uploads from ねこばたけ',
231289
},
232290
'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,
233298
}]
234299

235300
def _entries(self, user_id):

0 commit comments

Comments
 (0)