diff options
author | Dong Heon Hee <hui1601@naver.com> | 2024-11-04 08:08:41 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-03 23:08:41 +0000 |
commit | 9c6534da81e485b2325b3489ee4128943e6d3e4b (patch) | |
tree | d80043f190673dfdbf30c3a45fcc09d7dd04755c | |
parent | a403dcf9be20b49cbb3017328f4aaa352fb6d685 (diff) |
[ie/chzzk:video] Fix extraction (#11228)
Closes #11226
Authored by: hui1601
-rw-r--r-- | yt_dlp/extractor/chzzk.py | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/yt_dlp/extractor/chzzk.py b/yt_dlp/extractor/chzzk.py index e0b9980af..b9c5e3ac0 100644 --- a/yt_dlp/extractor/chzzk.py +++ b/yt_dlp/extractor/chzzk.py @@ -146,19 +146,33 @@ class CHZZKVideoIE(InfoExtractor): video_meta = self._download_json( f'https://api.chzzk.naver.com/service/v3/videos/{video_id}', video_id, note='Downloading video info', errnote='Unable to download video info')['content'] - formats, subtitles = self._extract_mpd_formats_and_subtitles( - f'https://apis.naver.com/neonplayer/vodplay/v1/playback/{video_meta["videoId"]}', video_id, - query={ - 'key': video_meta['inKey'], - 'env': 'real', - 'lc': 'en_US', - 'cpl': 'en_US', - }, note='Downloading video playback', errnote='Unable to download video playback') + + live_status = 'was_live' if video_meta.get('liveOpenDate') else 'not_live' + video_status = video_meta.get('vodStatus') + if video_status == 'UPLOAD': + playback = self._parse_json(video_meta['liveRewindPlaybackJson'], video_id) + formats, subtitles = self._extract_m3u8_formats_and_subtitles( + playback['media'][0]['path'], video_id, 'mp4', m3u8_id='hls') + elif video_status == 'ABR_HLS': + formats, subtitles = self._extract_mpd_formats_and_subtitles( + f'https://apis.naver.com/neonplayer/vodplay/v1/playback/{video_meta["videoId"]}', + video_id, query={ + 'key': video_meta['inKey'], + 'env': 'real', + 'lc': 'en_US', + 'cpl': 'en_US', + }) + else: + self.raise_no_formats( + f'Unknown video status detected: "{video_status}"', expected=True, video_id=video_id) + formats, subtitles = [], {} + live_status = 'post_live' if live_status == 'was_live' else None return { 'id': video_id, 'formats': formats, 'subtitles': subtitles, + 'live_status': live_status, **traverse_obj(video_meta, { 'title': ('videoTitle', {str}), 'thumbnail': ('thumbnailImageUrl', {url_or_none}), |