1 from __future__ import unicode_literals
5 from .common import InfoExtractor
6 from ..compat import compat_str
14 class YouJizzIE(InfoExtractor):
15 _VALID_URL = r'https?://(?:\w+\.)?youjizz\.com/videos/(?:[^/#?]*-(?P<id>\d+)\.html|embed/(?P<embed_id>\d+))'
17 'url': 'http://www.youjizz.com/videos/zeichentrick-1-2189178.html',
18 'md5': 'b1e1dfaa8bb9537d8b84eeda9cf4acf4',
22 'title': 'Zeichentrick 1',
27 'url': 'http://www.youjizz.com/videos/-2189178.html',
28 'only_matching': True,
30 'url': 'https://www.youjizz.com/videos/embed/31991001',
31 'only_matching': True,
34 def _real_extract(self, url):
35 mobj = re.match(self._VALID_URL, url)
36 video_id = mobj.group('id') or mobj.group('embed_id')
38 webpage = self._download_webpage(url, video_id)
40 title = self._html_search_regex(
41 r'<title>(.+?)</title>', webpage, 'title')
45 encodings = self._parse_json(
47 r'encodings\s*=\s*(\[.+?\]);\n', webpage, 'encodings',
49 video_id, fatal=False)
50 for encoding in encodings:
51 if not isinstance(encoding, dict):
53 format_url = encoding.get('filename')
54 if not isinstance(format_url, compat_str):
56 if determine_ext(format_url) == 'm3u8':
57 formats.extend(self._extract_m3u8_formats(
58 format_url, video_id, 'mp4', entry_protocol='m3u8_native',
59 m3u8_id='hls', fatal=False))
61 format_id = encoding.get('name') or encoding.get('quality')
62 height = int_or_none(self._search_regex(
63 r'^(\d+)[pP]', format_id, 'height', default=None))
66 'format_id': format_id,
75 # YouJizz's HTML5 player has invalid HTML
76 webpage = webpage.replace('"controls', '" controls')
77 info_dict = self._parse_html5_media_entries(
78 url, webpage, video_id)[0]
80 duration = parse_duration(self._search_regex(
81 r'<strong>Runtime:</strong>([^<]+)', webpage, 'duration',
83 uploader = self._search_regex(
84 r'<strong>Uploaded By:.*?<a[^>]*>([^<]+)', webpage, 'uploader',
90 'age_limit': self._rta_search(webpage),