]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/yinyuetai.py
Merge branch 'yinyuetai' of https://github.com/ping/youtube-dl into ping-yinyuetai
[yt-dlp.git] / youtube_dl / extractor / yinyuetai.py
CommitLineData
37c1e402 1# coding: utf-8
2from __future__ import unicode_literals
3
4from .common import InfoExtractor
5from ..utils import ExtractorError
6
7
8class YinYueTaiIE(InfoExtractor):
9 IE_NAME = 'yinyuetai:video'
10 _VALID_URL = r'https?://v\.yinyuetai\.com/video(/h5)?/(?P<id>[0-9]+)'
11 _TEST = {
12 'url': 'http://v.yinyuetai.com/video/2322376',
13 'md5': '6e3abe28d38e3a54b591f9f040595ce0',
14 'info_dict': {
15 'id': '2322376',
16 'ext': 'mp4',
17 'title': '少女时代_PARTY_Music Video Teaser',
18 'creator': '少女时代',
19 },
20 }
21
22 def _real_extract(self, url):
23 video_id = self._match_id(url)
24
25 info = self._download_json(
26 'http://ext.yinyuetai.com/main/get-h-mv-info?json=true&videoId=%s' % video_id, video_id,
27 'Downloading mv info')['videoInfo']['coreVideoInfo']
28
29 if info['error']:
30 raise ExtractorError(info['errorMsg'], expected=True)
31
32 formats = [
33 {'url': format_info['videoUrl'], 'format_id': format_info['qualityLevel'],
34 'format': format_info['qualityLevelName'], 'filesize': format_info['fileSize'],
35 'ext': 'mp4', 'preference': format_info['bitrate']}
36 for format_info in info['videoUrlModels']
37 ]
38 self._sort_formats(formats)
39
40 return {
41 'id': video_id,
42 'title': info['videoName'],
43 'thumbnail': info['bigHeadImage'],
44 'creator': info['artistNames'],
45 'duration': info['duration'],
46 'formats': formats,
47 }