bfi.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import extract_attributes
  4. class BFIPlayerIE(InfoExtractor):
  5. _WORKING = False
  6. IE_NAME = 'bfi:player'
  7. _VALID_URL = r'https?://player\.bfi\.org\.uk/[^/]+/film/watch-(?P<id>[\w-]+)-online'
  8. _TEST = {
  9. 'url': 'https://player.bfi.org.uk/free/film/watch-computer-doctor-1974-online',
  10. 'md5': 'e8783ebd8e061ec4bc6e9501ed547de8',
  11. 'info_dict': {
  12. 'id': 'htNnhlZjE60C9VySkQEIBtU-cNV1Xx63',
  13. 'ext': 'mp4',
  14. 'title': 'Computer Doctor',
  15. 'description': 'md5:fb6c240d40c4dbe40428bdd62f78203b',
  16. },
  17. 'skip': 'BFI Player films cannot be played outside of the UK',
  18. }
  19. def _real_extract(self, url):
  20. video_id = self._match_id(url)
  21. webpage = self._download_webpage(url, video_id)
  22. entries = []
  23. for player_el in re.findall(r'(?s)<[^>]+class="player"[^>]*>', webpage):
  24. player_attr = extract_attributes(player_el)
  25. ooyala_id = player_attr.get('data-video-id')
  26. if not ooyala_id:
  27. continue
  28. entries.append(self.url_result(
  29. 'ooyala:' + ooyala_id, 'Ooyala',
  30. ooyala_id, player_attr.get('data-label')))
  31. return self.playlist_result(entries)