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