]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/keezmovies.py
Update changelog.
[youtubedl] / youtube_dl / extractor / keezmovies.py
1 from __future__ import unicode_literals
2
3 import os
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import (
8 compat_urllib_parse_urlparse,
9 compat_urllib_request,
10 compat_urllib_parse,
11 )
12 from ..aes import (
13 aes_decrypt_text
14 )
15
16
17 class KeezMoviesIE(InfoExtractor):
18 _VALID_URL = r'^https?://(?:www\.)?keezmovies\.com/video/.+?(?P<videoid>[0-9]+)(?:[/?&]|$)'
19 _TEST = {
20 'url': 'http://www.keezmovies.com/video/petite-asian-lady-mai-playing-in-bathtub-1214711',
21 'file': '1214711.mp4',
22 'md5': '6e297b7e789329923fcf83abb67c9289',
23 'info_dict': {
24 'title': 'Petite Asian Lady Mai Playing In Bathtub',
25 'age_limit': 18,
26 }
27 }
28
29 def _real_extract(self, url):
30 mobj = re.match(self._VALID_URL, url)
31 video_id = mobj.group('videoid')
32
33 req = compat_urllib_request.Request(url)
34 req.add_header('Cookie', 'age_verified=1')
35 webpage = self._download_webpage(req, video_id)
36
37 # embedded video
38 mobj = re.search(r'href="([^"]+)"></iframe>', webpage)
39 if mobj:
40 embedded_url = mobj.group(1)
41 return self.url_result(embedded_url)
42
43 video_title = self._html_search_regex(r'<h1 [^>]*>([^<]+)', webpage, 'title')
44 video_url = compat_urllib_parse.unquote(self._html_search_regex(r'video_url=(.+?)&amp;', webpage, 'video_url'))
45 if 'encrypted=true' in webpage:
46 password = self._html_search_regex(r'video_title=(.+?)&amp;', webpage, 'password')
47 video_url = aes_decrypt_text(video_url, password, 32).decode('utf-8')
48 path = compat_urllib_parse_urlparse(video_url).path
49 extension = os.path.splitext(path)[1][1:]
50 format = path.split('/')[4].split('_')[:2]
51 format = "-".join(format)
52
53 age_limit = self._rta_search(webpage)
54
55 return {
56 'id': video_id,
57 'title': video_title,
58 'url': video_url,
59 'ext': extension,
60 'format': format,
61 'format_id': format,
62 'age_limit': age_limit,
63 }