]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/yinyuetai.py
[ie/box] Fix formats extraction (#8649)
[yt-dlp.git] / yt_dlp / extractor / yinyuetai.py
1 from .common import InfoExtractor
2 from ..utils import ExtractorError
3
4
5 class YinYueTaiIE(InfoExtractor):
6 IE_NAME = 'yinyuetai:video'
7 IE_DESC = '音悦Tai'
8 _VALID_URL = r'https?://v\.yinyuetai\.com/video(?:/h5)?/(?P<id>[0-9]+)'
9 _TESTS = [{
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': '少女时代',
17 'duration': 25,
18 'thumbnail': r're:^https?://.*\.jpg$',
19 },
20 }, {
21 'url': 'http://v.yinyuetai.com/video/h5/2322376',
22 'only_matching': True,
23 }]
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
35 formats = [{
36 'url': format_info['videoUrl'],
37 'format_id': format_info['qualityLevel'],
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
41 'ext': 'mp4',
42 'tbr': format_info.get('bitrate'),
43 } for format_info in info['videoUrlModels']]
44
45 return {
46 'id': video_id,
47 'title': info['videoName'],
48 'thumbnail': info.get('bigHeadImage'),
49 'creator': info.get('artistNames'),
50 'duration': info.get('duration'),
51 'formats': formats,
52 }