wayofthemaster.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import determine_ext
  5. class WayOfTheMasterIE(InfoExtractor):
  6. _VALID_URL = r'https?://www\.wayofthemaster\.com/([^/?#]*/)*(?P<id>[^/?#]+)\.s?html(?:$|[?#])'
  7. _TEST = {
  8. 'url': 'http://www.wayofthemaster.com/hbks.shtml',
  9. 'md5': '5316b57487ada8480606a93cb3d18d24',
  10. 'info_dict': {
  11. 'id': 'hbks',
  12. 'ext': 'mp4',
  13. 'title': 'Intelligent Design vs. Evolution',
  14. },
  15. }
  16. def _real_extract(self, url):
  17. mobj = re.match(self._VALID_URL, url)
  18. video_id = mobj.group('id')
  19. webpage = self._download_webpage(url, video_id)
  20. title = self._search_regex(
  21. r'<img src="images/title_[^"]+".*?alt="([^"]+)"',
  22. webpage, 'title', default=None)
  23. if title is None:
  24. title = self._html_search_regex(
  25. r'<title>(.*?)</title>', webpage, 'page title')
  26. url_base = self._search_regex(
  27. r'<param\s+name="?movie"?\s+value=".*?/wotm_videoplayer_highlow[0-9]*\.swf\?vid=([^"]+)"',
  28. webpage, 'URL base')
  29. formats = [{
  30. 'format_id': 'low',
  31. 'quality': 1,
  32. 'url': url_base + '_low.mp4',
  33. }, {
  34. 'format_id': 'high',
  35. 'quality': 2,
  36. 'url': url_base + '_high.mp4',
  37. }]
  38. self._sort_formats(formats)
  39. return {
  40. 'id': video_id,
  41. 'title': title,
  42. 'formats': formats,
  43. }