You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.9 KiB

10 years ago
10 years ago
10 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import ExtractorError
  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': 're:^https?://.*\.jpg$',
  19. },
  20. }, {
  21. 'url': 'http://v.yinyuetai.com/video/h5/2322376',
  22. 'only_matching': True,
  23. }]
  24. def _real_extract(self, url):
  25. video_id = self._match_id(url)
  26. info = self._download_json(
  27. 'http://ext.yinyuetai.com/main/get-h-mv-info?json=true&videoId=%s' % video_id, video_id,
  28. 'Downloading mv info')['videoInfo']['coreVideoInfo']
  29. if info['error']:
  30. raise ExtractorError(info['errorMsg'], expected=True)
  31. formats = [{
  32. 'url': format_info['videoUrl'],
  33. 'format_id': format_info['qualityLevel'],
  34. 'format': format_info.get('qualityLevelName'),
  35. 'filesize': format_info.get('fileSize'),
  36. # though URLs ends with .flv, the downloaded files are in fact mp4
  37. 'ext': 'mp4',
  38. 'tbr': format_info.get('bitrate'),
  39. } for format_info in info['videoUrlModels']]
  40. self._sort_formats(formats)
  41. return {
  42. 'id': video_id,
  43. 'title': info['videoName'],
  44. 'thumbnail': info.get('bigHeadImage'),
  45. 'creator': info.get('artistNames'),
  46. 'duration': info.get('duration'),
  47. 'formats': formats,
  48. }