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.

53 lines
1.7 KiB

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