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.

57 lines
1.8 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. ExtractorError,
  6. unified_strdate,
  7. )
  8. class ParliamentLiveUKIE(InfoExtractor):
  9. IE_NAME = 'parliamentlive.tv'
  10. IE_DESC = 'UK parliament videos'
  11. _VALID_URL = r'https?://www\.parliamentlive\.tv/Main/Player\.aspx\?(?:[^&]+&)*?meetingId=(?P<id>[0-9]+)'
  12. _TEST = {
  13. 'url': 'http://www.parliamentlive.tv/Main/Player.aspx?meetingId=15121&player=windowsmedia',
  14. 'info_dict': {
  15. 'id': '15121',
  16. 'ext': 'asf',
  17. 'title': 'hoc home affairs committee, 18 mar 2014.pm',
  18. 'description': 'md5:033b3acdf83304cd43946b2d5e5798d1',
  19. },
  20. 'params': {
  21. 'skip_download': True, # Requires mplayer (mms)
  22. }
  23. }
  24. def _real_extract(self, url):
  25. mobj = re.match(self._VALID_URL, url)
  26. video_id = mobj.group('id')
  27. webpage = self._download_webpage(url, video_id)
  28. asx_url = self._html_search_regex(
  29. r'embed.*?src="([^"]+)" name="MediaPlayer"', webpage,
  30. 'metadata URL')
  31. asx = self._download_xml(asx_url, video_id, 'Downloading ASX metadata')
  32. video_url = asx.find('.//REF').attrib['HREF']
  33. title = self._search_regex(
  34. r'''(?x)player\.setClipDetails\(
  35. (?:(?:[0-9]+|"[^"]+"),\s*){2}
  36. "([^"]+",\s*"[^"]+)"
  37. ''',
  38. webpage, 'title').replace('", "', ', ')
  39. description = self._html_search_regex(
  40. r'(?s)<span id="MainContentPlaceHolder_CaptionsBlock_WitnessInfo">(.*?)</span>',
  41. webpage, 'description')
  42. return {
  43. 'id': video_id,
  44. 'ext': 'asf',
  45. 'url': video_url,
  46. 'title': title,
  47. 'description': description,
  48. }