]>
Commit | Line | Data |
---|---|---|
abf3494a | 1 | from .common import InfoExtractor |
3a40f859 S |
2 | from ..utils import ( |
3 | int_or_none, | |
4 | urljoin, | |
5 | ) | |
abf3494a | 6 | |
7 | ||
8 | class MelonVODIE(InfoExtractor): | |
3a40f859 | 9 | _VALID_URL = r'https?://vod\.melon\.com/video/detail2\.html?\?.*?mvId=(?P<id>[0-9]+)' |
abf3494a | 10 | _TEST = { |
11 | 'url': 'http://vod.melon.com/video/detail2.htm?mvId=50158734', | |
abf3494a | 12 | 'info_dict': { |
13 | 'id': '50158734', | |
14 | 'ext': 'mp4', | |
3a40f859 | 15 | 'title': "Jessica 'Wonderland' MV Making Film", |
ec85ded8 | 16 | 'thumbnail': r're:^https?://.*\.jpg$', |
abf3494a | 17 | 'artist': 'Jessica (제시카)', |
18 | 'upload_date': '20161212', | |
19 | 'duration': 203, | |
20 | }, | |
21 | 'params': { | |
22 | 'skip_download': 'm3u8 download', | |
23 | } | |
24 | } | |
25 | ||
26 | def _real_extract(self, url): | |
27 | video_id = self._match_id(url) | |
28 | ||
29 | play_info = self._download_json( | |
30 | 'http://vod.melon.com/video/playerInfo.json', video_id, | |
3a40f859 S |
31 | note='Downloading player info JSON', query={'mvId': video_id}) |
32 | ||
abf3494a | 33 | title = play_info['mvInfo']['MVTITLE'] |
abf3494a | 34 | |
35 | info = self._download_json( | |
36 | 'http://vod.melon.com/delivery/streamingInfo.json', video_id, | |
3a40f859 S |
37 | note='Downloading streaming info JSON', |
38 | query={ | |
39 | 'contsId': video_id, | |
40 | 'contsType': 'VIDEO', | |
41 | }) | |
42 | ||
43 | stream_info = info['streamingInfo'] | |
44 | ||
45 | formats = self._extract_m3u8_formats( | |
46 | stream_info['encUrl'], video_id, 'mp4', m3u8_id='hls') | |
abf3494a | 47 | self._sort_formats(formats) |
48 | ||
3a40f859 S |
49 | artist_list = play_info.get('artistList') |
50 | artist = None | |
51 | if isinstance(artist_list, list): | |
52 | artist = ', '.join( | |
53 | [a['ARTISTNAMEWEBLIST'] | |
54 | for a in artist_list if a.get('ARTISTNAMEWEBLIST')]) | |
55 | ||
56 | thumbnail = urljoin(info.get('staticDomain'), stream_info.get('imgPath')) | |
57 | ||
abf3494a | 58 | duration = int_or_none(stream_info.get('playTime')) |
3a40f859 | 59 | upload_date = stream_info.get('mvSvcOpenDt', '')[:8] or None |
abf3494a | 60 | |
61 | return { | |
62 | 'id': video_id, | |
63 | 'title': title, | |
64 | 'artist': artist, | |
65 | 'thumbnail': thumbnail, | |
66 | 'upload_date': upload_date, | |
67 | 'duration': duration, | |
68 | 'formats': formats | |
69 | } |