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.

55 lines
1.7 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. compat_urllib_parse,
  6. determine_ext,
  7. ExtractorError,
  8. )
  9. class AUEngineIE(InfoExtractor):
  10. _VALID_URL = r'http://(?:www\.)?auengine\.com/embed\.php\?.*?file=(?P<id>[^&]+).*?'
  11. _TEST = {
  12. 'url': 'http://auengine.com/embed.php?file=lfvlytY6&w=650&h=370',
  13. 'md5': '48972bdbcf1a3a2f5533e62425b41d4f',
  14. 'info_dict': {
  15. 'id': 'lfvlytY6',
  16. 'ext': 'mp4',
  17. 'title': '[Commie]The Legend of the Legendary Heroes - 03 - Replication Eye (Alpha Stigma)[F9410F5A]'
  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. title = self._html_search_regex(r'<title>(?P<title>.+?)</title>', webpage, 'title')
  25. title = title.strip()
  26. links = re.findall(r'\s(?:file|url):\s*["\']([^\'"]+)["\']', webpage)
  27. links = map(compat_urllib_parse.unquote, links)
  28. thumbnail = None
  29. video_url = None
  30. for link in links:
  31. if link.endswith('.png'):
  32. thumbnail = link
  33. elif '/videos/' in link:
  34. video_url = link
  35. if not video_url:
  36. raise ExtractorError('Could not find video URL')
  37. ext = '.' + determine_ext(video_url)
  38. if ext == title[-len(ext):]:
  39. title = title[:-len(ext)]
  40. return {
  41. 'id': video_id,
  42. 'url': video_url,
  43. 'title': title,
  44. 'thumbnail': thumbnail,
  45. 'http_referer': 'http://www.auengine.com/flowplayer/flowplayer.commercial-3.2.14.swf',
  46. }