[cleanup] Make more playlist entries lazy (#11763)
[yt-dlp.git] / yt_dlp / extractor / melonvod.py
blob05d9de8dc10e963ae2649373a487683ba0eb25f7
1 from .common import InfoExtractor
2 from ..utils import (
3 int_or_none,
4 urljoin,
8 class MelonVODIE(InfoExtractor):
9 _VALID_URL = r'https?://vod\.melon\.com/video/detail2\.html?\?.*?mvId=(?P<id>[0-9]+)'
10 _TEST = {
11 'url': 'http://vod.melon.com/video/detail2.htm?mvId=50158734',
12 'info_dict': {
13 'id': '50158734',
14 'ext': 'mp4',
15 'title': "Jessica 'Wonderland' MV Making Film",
16 'thumbnail': r're:^https?://.*\.jpg$',
17 'artist': 'Jessica (์ œ์‹œ์นด)',
18 'upload_date': '20161212',
19 'duration': 203,
21 'params': {
22 'skip_download': 'm3u8 download',
26 def _real_extract(self, url):
27 video_id = self._match_id(url)
29 play_info = self._download_json(
30 'http://vod.melon.com/video/playerInfo.json', video_id,
31 note='Downloading player info JSON', query={'mvId': video_id})
33 title = play_info['mvInfo']['MVTITLE']
35 info = self._download_json(
36 'http://vod.melon.com/delivery/streamingInfo.json', video_id,
37 note='Downloading streaming info JSON',
38 query={
39 'contsId': video_id,
40 'contsType': 'VIDEO',
43 stream_info = info['streamingInfo']
45 formats = self._extract_m3u8_formats(
46 stream_info['encUrl'], video_id, 'mp4', m3u8_id='hls')
48 artist_list = play_info.get('artistList')
49 artist = None
50 if isinstance(artist_list, list):
51 artist = ', '.join(
52 [a['ARTISTNAMEWEBLIST']
53 for a in artist_list if a.get('ARTISTNAMEWEBLIST')])
55 thumbnail = urljoin(info.get('staticDomain'), stream_info.get('imgPath'))
57 duration = int_or_none(stream_info.get('playTime'))
58 upload_date = stream_info.get('mvSvcOpenDt', '')[:8] or None
60 return {
61 'id': video_id,
62 'title': title,
63 'artist': artist,
64 'thumbnail': thumbnail,
65 'upload_date': upload_date,
66 'duration': duration,
67 'formats': formats,