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