]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/auengine.py
95c038003b431dc48ac3bb89dcc03f8aa39ea07f
[youtubedl] / youtube_dl / extractor / auengine.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import (
5 compat_urllib_parse,
6 determine_ext,
7 ExtractorError,
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'\s(?:file|url):\s*["\']([^\'"]+)["\']', webpage)
29 links = map(compat_urllib_parse.unquote, links)
30
31 thumbnail = None
32 video_url = None
33 for link in links:
34 if link.endswith('.png'):
35 thumbnail = link
36 elif '/videos/' in link:
37 video_url = link
38 if not video_url:
39 raise ExtractorError(u'Could not find video URL')
40 ext = u'.' + determine_ext(video_url)
41 if ext == title[-len(ext):]:
42 title = title[:-len(ext)]
43
44 return {
45 'id': video_id,
46 'url': video_url,
47 'title': title,
48 'thumbnail': thumbnail,
49 }