]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/keezmovies.py
[francetv] Restore support for jt videos
[yt-dlp.git] / youtube_dl / extractor / keezmovies.py
CommitLineData
43df5a7e
JMF
1from __future__ import unicode_literals
2
5b11143d 3import os
4import re
5
6from .common import InfoExtractor
1cc79574 7from ..compat import (
5b11143d 8 compat_urllib_parse_urlparse,
9 compat_urllib_request,
5b11143d 10)
11
43df5a7e 12
5b11143d 13class KeezMoviesIE(InfoExtractor):
1cc79574 14 _VALID_URL = r'https?://(?:www\.)?keezmovies\.com/video/.+?(?P<id>[0-9]+)(?:[/?&]|$)'
5b11143d 15 _TEST = {
43df5a7e 16 'url': 'http://www.keezmovies.com/video/petite-asian-lady-mai-playing-in-bathtub-1214711',
43df5a7e
JMF
17 'md5': '6e297b7e789329923fcf83abb67c9289',
18 'info_dict': {
9f281cac
PH
19 'id': '1214711',
20 'ext': 'mp4',
43df5a7e
JMF
21 'title': 'Petite Asian Lady Mai Playing In Bathtub',
22 'age_limit': 18,
5b11143d 23 }
24 }
25
26 def _real_extract(self, url):
1cc79574 27 video_id = self._match_id(url)
5b11143d 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)
5da05495 37 return self.url_result(embedded_url)
5b11143d 38
9f281cac
PH
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')
a56f9de1
JMF
43 path = compat_urllib_parse_urlparse(video_url).path
44 extension = os.path.splitext(path)[1][1:]
5b11143d 45 format = path.split('/')[4].split('_')[:2]
a56f9de1 46 format = "-".join(format)
5b11143d 47
750e9833
FV
48 age_limit = self._rta_search(webpage)
49
5b11143d 50 return {
51 'id': video_id,
52 'title': video_title,
53 'url': video_url,
54 'ext': extension,
55 'format': format,
56 'format_id': format,
750e9833 57 'age_limit': age_limit,
5b11143d 58 }