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.

78 lines
3.0 KiB

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