1 from __future__ import unicode_literals
5 from .common import InfoExtractor
11 class YouJizzIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:\w+\.)?youjizz\.com/videos/[^/#?]+-(?P<id>[0-9]+)\.html(?:$|[?#])'
14 'url': 'http://www.youjizz.com/videos/zeichentrick-1-2189178.html',
15 'md5': '07e15fa469ba384c7693fd246905547c',
19 'title': 'Zeichentrick 1',
24 def _real_extract(self, url):
25 video_id = self._match_id(url)
26 webpage = self._download_webpage(url, video_id)
27 age_limit = self._rta_search(webpage)
28 video_title = self._html_search_regex(
29 r'<title>\s*(.*)\s*</title>', webpage, 'title')
31 embed_page_url = self._search_regex(
32 r'(https?://www.youjizz.com/videos/embed/[0-9]+)',
33 webpage, 'embed page')
34 webpage = self._download_webpage(
35 embed_page_url, video_id, note='downloading embed page')
38 m_playlist = re.search(r'so.addVariable\("playlist", ?"(?P<playlist>.+?)"\);', webpage)
39 if m_playlist is not None:
40 playlist_url = m_playlist.group('playlist')
41 playlist_page = self._download_webpage(playlist_url, video_id,
42 'Downloading playlist page')
43 m_levels = list(re.finditer(r'<level bitrate="(\d+?)" file="(.*?)"', playlist_page))
44 if len(m_levels) == 0:
45 raise ExtractorError('Unable to extract video url')
46 videos = [(int(m.group(1)), m.group(2)) for m in m_levels]
47 (_, video_url) = sorted(videos)[0]
48 video_url = video_url.replace('%252F', '%2F')
50 video_url = self._search_regex(r'so.addVariable\("file",encodeURIComponent\("(?P<source>[^"]+)"\)\);',
59 'player_url': embed_page_url,
60 'age_limit': age_limit,