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.

76 lines
3.0 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. parse_duration,
  6. unified_strdate,
  7. )
  8. class MusicVaultIE(InfoExtractor):
  9. _VALID_URL = r'https?://www\.musicvault\.com/(?P<uploader_id>[^/?#]*)/video/(?P<display_id>[^/?#]*)_(?P<id>[0-9]+)\.html'
  10. _TEST = {
  11. 'url': 'http://www.musicvault.com/the-allman-brothers-band/video/straight-from-the-heart_1010863.html',
  12. 'md5': '2cdbb3ae75f7fb3519821507d2fb3c15',
  13. 'info_dict': {
  14. 'id': '1010863',
  15. 'ext': 'mp4',
  16. 'uploader_id': 'the-allman-brothers-band',
  17. 'title': 'Straight from the Heart',
  18. 'duration': 244,
  19. 'uploader': 'The Allman Brothers Band',
  20. 'thumbnail': 're:^https?://.*/thumbnail/.*',
  21. 'upload_date': '19811216',
  22. 'location': 'Capitol Theatre (Passaic, NJ)',
  23. 'description': 'Listen to The Allman Brothers Band perform Straight from the Heart at Capitol Theatre (Passaic, NJ) on Dec 16, 1981',
  24. }
  25. }
  26. def _real_extract(self, url):
  27. mobj = re.match(self._VALID_URL, url)
  28. display_id = mobj.group('display_id')
  29. webpage = self._download_webpage(url, display_id)
  30. thumbnail = self._search_regex(
  31. r'<meta itemprop="thumbnail" content="([^"]+)"',
  32. webpage, 'thumbnail', fatal=False)
  33. data_div = self._search_regex(
  34. r'(?s)<div class="data">(.*?)</div>', webpage, 'data fields')
  35. uploader = self._html_search_regex(
  36. r'<h1.*?>(.*?)</h1>', data_div, 'uploader', fatal=False)
  37. title = self._html_search_regex(
  38. r'<h2.*?>(.*?)</h2>', data_div, 'title')
  39. upload_date = unified_strdate(self._html_search_regex(
  40. r'<h3.*?>(.*?)</h3>', data_div, 'uploader', fatal=False))
  41. location = self._html_search_regex(
  42. r'<h4.*?>(.*?)</h4>', data_div, 'location', fatal=False)
  43. duration = parse_duration(self._html_search_meta('duration', webpage))
  44. VIDEO_URL_TEMPLATE = 'http://cdnapi.kaltura.com/p/%(uid)s/sp/%(wid)s/playManifest/entryId/%(entry_id)s/format/url/protocol/http'
  45. kaltura_id = self._search_regex(
  46. r'<div id="video-detail-player" data-kaltura-id="([^"]+)"',
  47. webpage, 'kaltura ID')
  48. video_url = VIDEO_URL_TEMPLATE % {
  49. 'entry_id': kaltura_id,
  50. 'wid': self._search_regex(r'/wid/_([0-9]+)/', webpage, 'wid'),
  51. 'uid': self._search_regex(r'uiconf_id/([0-9]+)/', webpage, 'uid'),
  52. }
  53. return {
  54. 'id': mobj.group('id'),
  55. 'url': video_url,
  56. 'ext': 'mp4',
  57. 'display_id': display_id,
  58. 'uploader_id': mobj.group('uploader_id'),
  59. 'thumbnail': thumbnail,
  60. 'description': self._html_search_meta('description', webpage),
  61. 'upload_date': upload_date,
  62. 'location': location,
  63. 'title': title,
  64. 'uploader': uploader,
  65. 'duration': duration,
  66. }