auengine.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import os.path
  2. import re
  3. import urllib
  4. import urlparse
  5. from .common import InfoExtractor
  6. class AuengineIE(InfoExtractor):
  7. _VALID_URL = r'(?:http://)?(?:www\.)?auengine\.com/embed.php\?.*?file=([^&]+).*?'
  8. def _real_extract(self, url):
  9. mobj = re.match(self._VALID_URL, url)
  10. video_id = mobj.group(1)
  11. webpage = self._download_webpage(url, video_id)
  12. title = self._html_search_regex(r'<title>(?P<title>.+?)</title>',
  13. webpage, u'title')
  14. title = title.strip()
  15. links = re.findall(r'[^A-Za-z0-9]?(?:file|url):\s*["\'](http[^\'"&]*)', webpage)
  16. links = [urllib.unquote(l) for l in links]
  17. for link in links:
  18. root, pathext = os.path.splitext(urlparse.urlparse(link).path)
  19. if pathext == '.png':
  20. thumbnail = link
  21. elif pathext == '.mp4':
  22. url = link
  23. ext = pathext
  24. if ext == title[-len(ext):]:
  25. title = title[:-len(ext)]
  26. ext = ext[1:]
  27. return [{
  28. 'id': video_id,
  29. 'url': url,
  30. 'ext': ext,
  31. 'title': title,
  32. 'thumbnail': thumbnail,
  33. }]