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.

52 lines
1.6 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. _TEST = {
  11. 'url': 'http://auengine.com/embed.php?file=lfvlytY6&w=650&h=370',
  12. 'file': 'lfvlytY6.mp4',
  13. 'md5': '48972bdbcf1a3a2f5533e62425b41d4f',
  14. 'info_dict': {
  15. 'title': '[Commie]The Legend of the Legendary Heroes - 03 - Replication Eye (Alpha Stigma)[F9410F5A]'
  16. }
  17. }
  18. _VALID_URL = r'(?:http://)?(?:www\.)?auengine\.com/embed\.php\?.*?file=([^&]+).*?'
  19. def _real_extract(self, url):
  20. mobj = re.match(self._VALID_URL, url)
  21. video_id = mobj.group(1)
  22. webpage = self._download_webpage(url, video_id)
  23. title = self._html_search_regex(r'<title>(?P<title>.+?)</title>',
  24. 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(u'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. }