Skip to content

Commit

Permalink
Use _download_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
urectanc committed Jun 27, 2023
1 parent 4218f95 commit 106928a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
10 changes: 2 additions & 8 deletions yt_dlp/extractor/stacommu.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,8 @@ class StacommuVODIE(StacommuBaseIE):

def _real_extract(self, url):
video_id = self._match_id(url)
video_info = self._call_api(video_id, msg='video information', auth=False, fatal=False)
if not video_info:
webpage = self._download_webpage(url, video_id)
nextjs_data = self._search_nextjs_data(webpage, video_id)
video_info = traverse_obj(
nextjs_data,
('props', 'pageProps', 'dehydratedState', 'queries', 0, 'state', 'data', {dict})
) or {}
video_info = self._download_metadata(
url, video_id, 'ja', ('dehydratedState', 'queries', 0, 'state', 'data'))
hls_info, decrypt = self._call_encrypted_api(
video_id, ':watch', 'stream information', data={'method': 1})

Expand Down
8 changes: 4 additions & 4 deletions yt_dlp/extractor/wrestleuniverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ def decrypt(data):
}, query=query, fatal=fatal)
return api_json, decrypt

def _download_metadata(self, url, video_id, lang, props_key):
def _download_metadata(self, url, video_id, lang, props_keys):
metadata = self._call_api(video_id, msg='metadata', query={'al': lang or 'ja'}, auth=False, fatal=False)
if not metadata:
webpage = self._download_webpage(url, video_id)
nextjs_data = self._search_nextjs_data(webpage, video_id)
metadata = traverse_obj(nextjs_data, ('props', 'pageProps', props_key, {dict})) or {}
metadata = traverse_obj(nextjs_data, ('props', 'pageProps', *props_keys, {dict})) or {}
return metadata

def _get_formats(self, data, path, video_id=None):
Expand Down Expand Up @@ -187,7 +187,7 @@ class WrestleUniverseVODIE(WrestleUniverseBaseIE):

def _real_extract(self, url):
lang, video_id = self._match_valid_url(url).group('lang', 'id')
metadata = self._download_metadata(url, video_id, lang, 'videoEpisodeFallbackData')
metadata = self._download_metadata(url, video_id, lang, ('videoEpisodeFallbackData',))
video_data = self._call_api(video_id, ':watch', 'watch', data={
# 'deviceId' is required if ignoreDeviceRestriction is False
'ignoreDeviceRestriction': True,
Expand Down Expand Up @@ -266,7 +266,7 @@ class WrestleUniversePPVIE(WrestleUniverseBaseIE):

def _real_extract(self, url):
lang, video_id = self._match_valid_url(url).group('lang', 'id')
metadata = self._download_metadata(url, video_id, lang, 'eventFallbackData')
metadata = self._download_metadata(url, video_id, lang, ('eventFallbackData',))

info = {
'id': video_id,
Expand Down

0 comments on commit 106928a

Please sign in to comment.