macgamestore.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import ExtractorError
  4. class MacGameStoreIE(InfoExtractor):
  5. IE_NAME = u'macgamestore'
  6. IE_DESC = u'MacGameStore trailers'
  7. _VALID_URL = r'https?://www\.macgamestore\.com/mediaviewer\.php\?trailer=(?P<id>\d+)'
  8. _TEST = {
  9. u'url': u'http://www.macgamestore.com/mediaviewer.php?trailer=2450',
  10. u'file': u'2450.m4v',
  11. u'md5': u'8649b8ea684b6666b4c5be736ecddc61',
  12. u'info_dict': {
  13. u'title': u'Crow',
  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, u'Downloading trailer page')
  20. if re.search(r'>Missing Media<', webpage) is not None:
  21. raise ExtractorError(u'Trailer %s does not exist' % video_id, expected=True)
  22. mobj = re.search(r'<title>MacGameStore: (?P<title>.*?) Trailer</title>', webpage)
  23. video_title = mobj.group('title')
  24. mobj = re.search(r'(?s)<div\s+id="video-player".*?href="(?P<video>[^"]+)"\s*>', webpage)
  25. video_url = mobj.group('video')
  26. return {
  27. 'id': video_id,
  28. 'url': video_url,
  29. 'title': video_title
  30. }