criterion.py 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. # -*- coding: utf-8 -*-
  2. import re
  3. from .common import InfoExtractor
  4. class CriterionIE(InfoExtractor):
  5. _VALID_URL = r'http://www.criterion.com/films/(.*)'
  6. def _real_extract(self, url):
  7. mobj = re.match(self._VALID_URL, url)
  8. video_id = mobj.group(1).split('-')[0]
  9. webpage = self._download_webpage(url, video_id)
  10. final_url = self._search_regex(r'so.addVariable\("videoURL", "(.+?)"\)\;',
  11. webpage, 'video url')
  12. title = self._search_regex(r'<meta content="(.+?)" property="og:title" />',
  13. webpage, 'video title')
  14. description = self._search_regex(r'<meta name="description" content="(.+?)" />',
  15. webpage, 'video description')
  16. thumbnail = self._search_regex(r'so.addVariable\("thumbnailURL", "(.+?)"\)\;',
  17. webpage, 'thumbnail url')
  18. ext = final_url.split('.')[-1]
  19. return {'id': video_id,
  20. 'url' : final_url,
  21. 'title': title,
  22. 'ext': ext,
  23. 'description': description,
  24. 'thumbnail': thumbnail,
  25. }