]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/auengine.py
debian/watch: Make use of the signing key from upstream.
[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 _VALID_URL = r'http://(?:www\.)?auengine\.com/embed\.php\?.*?file=(?P<id>[^&]+).*?'
15
16 _TEST = {
17 'url': 'http://auengine.com/embed.php?file=lfvlytY6&w=650&h=370',
18 'md5': '48972bdbcf1a3a2f5533e62425b41d4f',
19 'info_dict': {
20 'id': 'lfvlytY6',
21 'ext': 'mp4',
22 'title': '[Commie]The Legend of the Legendary Heroes - 03 - Replication Eye (Alpha Stigma)[F9410F5A]'
23 }
24 }
25
26 def _real_extract(self, url):
27 mobj = re.match(self._VALID_URL, url)
28 video_id = mobj.group('id')
29
30 webpage = self._download_webpage(url, video_id)
31 title = self._html_search_regex(r'<title>(?P<title>.+?)</title>', webpage, 'title')
32 title = title.strip()
33 links = re.findall(r'\s(?:file|url):\s*["\']([^\'"]+)["\']', webpage)
34 links = map(compat_urllib_parse.unquote, links)
35
36 thumbnail = None
37 video_url = None
38 for link in links:
39 if link.endswith('.png'):
40 thumbnail = link
41 elif '/videos/' in link:
42 video_url = link
43 if not video_url:
44 raise ExtractorError('Could not find video URL')
45 ext = '.' + determine_ext(video_url)
46 if ext == title[-len(ext):]:
47 title = title[:-len(ext)]
48
49 return {
50 'id': video_id,
51 'url': video_url,
52 'title': title,
53 'thumbnail': thumbnail,
54 'http_referer': 'http://www.auengine.com/flowplayer/flowplayer.commercial-3.2.14.swf',
55 }