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