]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/auengine.py
Update changelog.
[youtubedl] / 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 _TEST = {
12 u'url': u'http://auengine.com/embed.php?file=lfvlytY6&w=650&h=370',
13 u'file': u'lfvlytY6.mp4',
14 u'md5': u'48972bdbcf1a3a2f5533e62425b41d4f',
15 u'info_dict': {
16 u"title": u"[Commie]The Legend of the Legendary Heroes - 03 - Replication Eye (Alpha Stigma)[F9410F5A]"
17 }
18 }
19 _VALID_URL = r'(?:http://)?(?:www\.)?auengine\.com/embed.php\?.*?file=([^&]+).*?'
20
21 def _real_extract(self, url):
22 mobj = re.match(self._VALID_URL, url)
23 video_id = mobj.group(1)
24 webpage = self._download_webpage(url, video_id)
25 title = self._html_search_regex(r'<title>(?P<title>.+?)</title>',
26 webpage, u'title')
27 title = title.strip()
28 links = re.findall(r'[^A-Za-z0-9]?(?:file|url):\s*["\'](http[^\'"&]*)', webpage)
29 links = [compat_urllib_parse.unquote(l) for l in links]
30 for link in links:
31 root, pathext = os.path.splitext(compat_urllib_parse_urlparse(link).path)
32 if pathext == '.png':
33 thumbnail = link
34 elif pathext == '.mp4':
35 url = link
36 ext = pathext
37 if ext == title[-len(ext):]:
38 title = title[:-len(ext)]
39 ext = ext[1:]
40 return [{
41 'id': video_id,
42 'url': url,
43 'ext': ext,
44 'title': title,
45 'thumbnail': thumbnail,
46 }]