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.

49 lines
1.6 KiB

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