]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/auengine.py
Merge remote-tracking branch 'jaimeMF/yt-toplists'
[yt-dlp.git] / youtube_dl / extractor / auengine.py
CommitLineData
62008f69 1import re
62008f69
AK
2
3from .common import InfoExtractor
e4decf27
AK
4from ..utils import (
5 compat_urllib_parse,
9906d397
PH
6 determine_ext,
7 ExtractorError,
e4decf27 8)
62008f69 9
d798e1c7 10class AUEngineIE(InfoExtractor):
5d2eac9e
PH
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 }
c0ade33e 19 _VALID_URL = r'(?:http://)?(?:www\.)?auengine\.com/embed\.php\?.*?file=([^&]+).*?'
62008f69
AK
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()
9906d397
PH
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
62008f69 33 for link in links:
9906d397 34 if link.endswith('.png'):
62008f69 35 thumbnail = link
9906d397
PH
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)
62008f69
AK
41 if ext == title[-len(ext):]:
42 title = title[:-len(ext)]
9906d397
PH
43
44 return {
62008f69 45 'id': video_id,
9906d397 46 'url': video_url,
62008f69
AK
47 'title': title,
48 'thumbnail': thumbnail,
9906d397 49 }