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.

55 lines
1.8 KiB

  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. _VALID_URL = r'https?://v\.yinyuetai\.com/video(?:/h5)?/(?P<id>[0-9]+)'
  8. _TESTS = [{
  9. 'url': 'http://v.yinyuetai.com/video/2322376',
  10. 'md5': '6e3abe28d38e3a54b591f9f040595ce0',
  11. 'info_dict': {
  12. 'id': '2322376',
  13. 'ext': 'mp4',
  14. 'title': '少女时代_PARTY_Music Video Teaser',
  15. 'creator': '少女时代',
  16. 'duration': 25,
  17. 'thumbnail': 're:^https?://.*\.jpg$',
  18. },
  19. }, {
  20. 'url': 'http://v.yinyuetai.com/video/h5/2322376',
  21. 'only_matching': True,
  22. }]
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  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. if info['error']:
  29. raise ExtractorError(info['errorMsg'], expected=True)
  30. formats = [{
  31. 'url': format_info['videoUrl'],
  32. 'format_id': format_info['qualityLevel'],
  33. 'format': format_info.get('qualityLevelName'),
  34. 'filesize': format_info.get('fileSize'),
  35. # though URLs ends with .flv, the downloaded files are in fact mp4
  36. 'ext': 'mp4',
  37. 'tbr': format_info.get('bitrate'),
  38. } for format_info in info['videoUrlModels']]
  39. self._sort_formats(formats)
  40. return {
  41. 'id': video_id,
  42. 'title': info['videoName'],
  43. 'thumbnail': info.get('bigHeadImage'),
  44. 'creator': info.get('artistNames'),
  45. 'duration': info.get('duration'),
  46. 'formats': formats,
  47. }