]>
Commit | Line | Data |
---|---|---|
37c1e402 | 1 | from .common import InfoExtractor |
2 | from ..utils import ExtractorError | |
3 | ||
4 | ||
5 | class YinYueTaiIE(InfoExtractor): | |
6 | IE_NAME = 'yinyuetai:video' | |
b931fbe5 | 7 | IE_DESC = '音悦Tai' |
082a0140 | 8 | _VALID_URL = r'https?://v\.yinyuetai\.com/video(?:/h5)?/(?P<id>[0-9]+)' |
e2082ea9 | 9 | _TESTS = [{ |
37c1e402 | 10 | 'url': 'http://v.yinyuetai.com/video/2322376', |
11 | 'md5': '6e3abe28d38e3a54b591f9f040595ce0', | |
12 | 'info_dict': { | |
13 | 'id': '2322376', | |
14 | 'ext': 'mp4', | |
15 | 'title': '少女时代_PARTY_Music Video Teaser', | |
16 | 'creator': '少女时代', | |
d76dea00 | 17 | 'duration': 25, |
ec85ded8 | 18 | 'thumbnail': r're:^https?://.*\.jpg$', |
37c1e402 | 19 | }, |
e2082ea9 YCH |
20 | }, { |
21 | 'url': 'http://v.yinyuetai.com/video/h5/2322376', | |
22 | 'only_matching': True, | |
23 | }] | |
37c1e402 | 24 | |
25 | def _real_extract(self, url): | |
26 | video_id = self._match_id(url) | |
27 | ||
28 | info = self._download_json( | |
29 | 'http://ext.yinyuetai.com/main/get-h-mv-info?json=true&videoId=%s' % video_id, video_id, | |
30 | 'Downloading mv info')['videoInfo']['coreVideoInfo'] | |
31 | ||
32 | if info['error']: | |
33 | raise ExtractorError(info['errorMsg'], expected=True) | |
34 | ||
af0f9b0e YCH |
35 | formats = [{ |
36 | 'url': format_info['videoUrl'], | |
37 | 'format_id': format_info['qualityLevel'], | |
d76dea00 YCH |
38 | 'format': format_info.get('qualityLevelName'), |
39 | 'filesize': format_info.get('fileSize'), | |
40 | # though URLs ends with .flv, the downloaded files are in fact mp4 | |
af0f9b0e | 41 | 'ext': 'mp4', |
d76dea00 | 42 | 'tbr': format_info.get('bitrate'), |
af0f9b0e | 43 | } for format_info in info['videoUrlModels']] |
37c1e402 | 44 | |
45 | return { | |
46 | 'id': video_id, | |
47 | 'title': info['videoName'], | |
d76dea00 YCH |
48 | 'thumbnail': info.get('bigHeadImage'), |
49 | 'creator': info.get('artistNames'), | |
50 | 'duration': info.get('duration'), | |
37c1e402 | 51 | 'formats': formats, |
52 | } |