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