]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[yinyuetai] New extractor for yinyuetai.com
authorping <lipng.ong@gmail.com>
Mon, 6 Jul 2015 07:26:49 +0000 (15:26 +0800)
committerping <lipng.ong@gmail.com>
Mon, 6 Jul 2015 07:26:49 +0000 (15:26 +0800)
youtube_dl/extractor/__init__.py
youtube_dl/extractor/yinyuetai.py [new file with mode: 0644]

index aba62db53232e7ab9a90b3f7734999fcf5010bc4..8665855eb37a17f1a24fd3affb518d8b2a5e5120 100644 (file)
@@ -733,6 +733,7 @@ from .yandexmusic import (
     YandexMusicPlaylistIE,
 )
 from .yesjapan import YesJapanIE
+from .yinyuetai import YinYueTaiIE
 from .ynet import YnetIE
 from .youjizz import YouJizzIE
 from .youku import YoukuIE
diff --git a/youtube_dl/extractor/yinyuetai.py b/youtube_dl/extractor/yinyuetai.py
new file mode 100644 (file)
index 0000000..661c346
--- /dev/null
@@ -0,0 +1,47 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+from ..utils import ExtractorError
+
+
+class YinYueTaiIE(InfoExtractor):
+    IE_NAME = 'yinyuetai:video'
+    _VALID_URL = r'https?://v\.yinyuetai\.com/video(/h5)?/(?P<id>[0-9]+)'
+    _TEST = {
+        'url': 'http://v.yinyuetai.com/video/2322376',
+        'md5': '6e3abe28d38e3a54b591f9f040595ce0',
+        'info_dict': {
+            'id': '2322376',
+            'ext': 'mp4',
+            'title': '少女时代_PARTY_Music Video Teaser',
+            'creator': '少女时代',
+        },
+    }
+
+    def _real_extract(self, url):
+        video_id = self._match_id(url)
+
+        info = self._download_json(
+            'http://ext.yinyuetai.com/main/get-h-mv-info?json=true&videoId=%s' % video_id, video_id,
+            'Downloading mv info')['videoInfo']['coreVideoInfo']
+
+        if info['error']:
+            raise ExtractorError(info['errorMsg'], expected=True)
+
+        formats = [
+            {'url': format_info['videoUrl'], 'format_id': format_info['qualityLevel'],
+             'format': format_info['qualityLevelName'], 'filesize': format_info['fileSize'],
+             'ext': 'mp4', 'preference': format_info['bitrate']}
+            for format_info in info['videoUrlModels']
+        ]
+        self._sort_formats(formats)
+
+        return {
+            'id': video_id,
+            'title': info['videoName'],
+            'thumbnail': info['bigHeadImage'],
+            'creator': info['artistNames'],
+            'duration': info['duration'],
+            'formats': formats,
+        }