]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/youjizz.py
Update changelog.
[youtubedl] / youtube_dl / extractor / youjizz.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import (
5 ExtractorError,
6 )
7
8
9 class YouJizzIE(InfoExtractor):
10 _VALID_URL = r'^(?:https?://)?(?:\w+\.)?youjizz\.com/videos/(?P<videoid>[^.]+).html$'
11
12 def _real_extract(self, url):
13 mobj = re.match(self._VALID_URL, url)
14
15 video_id = mobj.group('videoid')
16
17 # Get webpage content
18 webpage = self._download_webpage(url, video_id)
19
20 # Get the video title
21 video_title = self._html_search_regex(r'<title>(?P<title>.*)</title>',
22 webpage, u'title').strip()
23
24 # Get the embed page
25 result = re.search(r'https?://www.youjizz.com/videos/embed/(?P<videoid>[0-9]+)', webpage)
26 if result is None:
27 raise ExtractorError(u'ERROR: unable to extract embed page')
28
29 embed_page_url = result.group(0).strip()
30 video_id = result.group('videoid')
31
32 webpage = self._download_webpage(embed_page_url, video_id)
33
34 # Get the video URL
35 video_url = self._search_regex(r'so.addVariable\("file",encodeURIComponent\("(?P<source>[^"]+)"\)\);',
36 webpage, u'video URL')
37
38 info = {'id': video_id,
39 'url': video_url,
40 'title': video_title,
41 'ext': 'flv',
42 'format': 'flv',
43 'player_url': embed_page_url}
44
45 return [info]