]>
Commit | Line | Data |
---|---|---|
0b76600d JMF |
1 | from __future__ import unicode_literals |
2 | ||
c3c77cec PH |
3 | import re |
4 | ||
5 | from .common import InfoExtractor | |
6 | from ..utils import ( | |
7 | ExtractorError, | |
8 | ) | |
9 | ||
10 | ||
11 | class YouJizzIE(InfoExtractor): | |
c0ade33e | 12 | _VALID_URL = r'^(?:https?://)?(?:\w+\.)?youjizz\.com/videos/(?P<videoid>[^.]+)\.html$' |
6f5ac90c | 13 | _TEST = { |
0b76600d JMF |
14 | 'url': 'http://www.youjizz.com/videos/zeichentrick-1-2189178.html', |
15 | 'file': '2189178.flv', | |
16 | 'md5': '07e15fa469ba384c7693fd246905547c', | |
17 | 'info_dict': { | |
18 | "title": "Zeichentrick 1", | |
19 | "age_limit": 18, | |
6f5ac90c PH |
20 | } |
21 | } | |
c3c77cec PH |
22 | |
23 | def _real_extract(self, url): | |
24 | mobj = re.match(self._VALID_URL, url) | |
25 | ||
26 | video_id = mobj.group('videoid') | |
27 | ||
28 | # Get webpage content | |
29 | webpage = self._download_webpage(url, video_id) | |
30 | ||
750e9833 FV |
31 | age_limit = self._rta_search(webpage) |
32 | ||
c3c77cec PH |
33 | # Get the video title |
34 | video_title = self._html_search_regex(r'<title>(?P<title>.*)</title>', | |
0b76600d | 35 | webpage, 'title').strip() |
c3c77cec PH |
36 | |
37 | # Get the embed page | |
38 | result = re.search(r'https?://www.youjizz.com/videos/embed/(?P<videoid>[0-9]+)', webpage) | |
39 | if result is None: | |
0b76600d | 40 | raise ExtractorError('ERROR: unable to extract embed page') |
c3c77cec PH |
41 | |
42 | embed_page_url = result.group(0).strip() | |
43 | video_id = result.group('videoid') | |
44 | ||
45 | webpage = self._download_webpage(embed_page_url, video_id) | |
46 | ||
47 | # Get the video URL | |
2e78b2be JMF |
48 | m_playlist = re.search(r'so.addVariable\("playlist", ?"(?P<playlist>.+?)"\);', webpage) |
49 | if m_playlist is not None: | |
50 | playlist_url = m_playlist.group('playlist') | |
51 | playlist_page = self._download_webpage(playlist_url, video_id, | |
0b76600d | 52 | 'Downloading playlist page') |
2e78b2be JMF |
53 | m_levels = list(re.finditer(r'<level bitrate="(\d+?)" file="(.*?)"', playlist_page)) |
54 | if len(m_levels) == 0: | |
0b76600d | 55 | raise ExtractorError('Unable to extract video url') |
2e78b2be JMF |
56 | videos = [(int(m.group(1)), m.group(2)) for m in m_levels] |
57 | (_, video_url) = sorted(videos)[0] | |
58 | video_url = video_url.replace('%252F', '%2F') | |
59 | else: | |
60 | video_url = self._search_regex(r'so.addVariable\("file",encodeURIComponent\("(?P<source>[^"]+)"\)\);', | |
0b76600d | 61 | webpage, 'video URL') |
c3c77cec | 62 | |
0b76600d JMF |
63 | return { |
64 | 'id': video_id, | |
65 | 'url': video_url, | |
66 | 'title': video_title, | |
67 | 'ext': 'flv', | |
68 | 'format': 'flv', | |
69 | 'player_url': embed_page_url, | |
70 | 'age_limit': age_limit, | |
71 | } |