]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/eroprofile.py
debian/changelog: Annotate bugs to close.
[youtubedl] / youtube_dl / extractor / eroprofile.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..compat import compat_urllib_parse
7 from ..utils import (
8 ExtractorError,
9 unescapeHTML
10 )
11
12
13 class EroProfileIE(InfoExtractor):
14 _VALID_URL = r'https?://(?:www\.)?eroprofile\.com/m/videos/view/(?P<id>[^/]+)'
15 _LOGIN_URL = 'http://www.eroprofile.com/auth/auth.php?'
16 _NETRC_MACHINE = 'eroprofile'
17 _TESTS = [{
18 'url': 'http://www.eroprofile.com/m/videos/view/sexy-babe-softcore',
19 'md5': 'c26f351332edf23e1ea28ce9ec9de32f',
20 'info_dict': {
21 'id': '3733775',
22 'display_id': 'sexy-babe-softcore',
23 'ext': 'm4v',
24 'title': 'sexy babe softcore',
25 'thumbnail': 're:https?://.*\.jpg',
26 'age_limit': 18,
27 }
28 }, {
29 'url': 'http://www.eroprofile.com/m/videos/view/Try-It-On-Pee_cut_2-wmv-4shared-com-file-sharing-download-movie-file',
30 'md5': '1baa9602ede46ce904c431f5418d8916',
31 'info_dict': {
32 'id': '1133519',
33 'ext': 'm4v',
34 'title': 'Try It On Pee_cut_2.wmv - 4shared.com - file sharing - download movie file',
35 'thumbnail': 're:https?://.*\.jpg',
36 'age_limit': 18,
37 },
38 'skip': 'Requires login',
39 }]
40
41 def _login(self):
42 (username, password) = self._get_login_info()
43 if username is None:
44 return
45
46 query = compat_urllib_parse.urlencode({
47 'username': username,
48 'password': password,
49 'url': 'http://www.eroprofile.com/',
50 })
51 login_url = self._LOGIN_URL + query
52 login_page = self._download_webpage(login_url, None, False)
53
54 m = re.search(r'Your username or password was incorrect\.', login_page)
55 if m:
56 raise ExtractorError(
57 'Wrong username and/or password.', expected=True)
58
59 self.report_login()
60 redirect_url = self._search_regex(
61 r'<script[^>]+?src="([^"]+)"', login_page, 'login redirect url')
62 self._download_webpage(redirect_url, None, False)
63
64 def _real_initialize(self):
65 self._login()
66
67 def _real_extract(self, url):
68 display_id = self._match_id(url)
69
70 webpage = self._download_webpage(url, display_id)
71
72 m = re.search(r'You must be logged in to view this video\.', webpage)
73 if m:
74 raise ExtractorError(
75 'This video requires login. Please specify a username and password and try again.', expected=True)
76
77 video_id = self._search_regex(
78 [r"glbUpdViews\s*\('\d*','(\d+)'", r'p/report/video/(\d+)'],
79 webpage, 'video id', default=None)
80
81 video_url = unescapeHTML(self._search_regex(
82 r'<source src="([^"]+)', webpage, 'video url'))
83 title = self._html_search_regex(
84 r'Title:</th><td>([^<]+)</td>', webpage, 'title')
85 thumbnail = self._search_regex(
86 r'onclick="showVideoPlayer\(\)"><img src="([^"]+)',
87 webpage, 'thumbnail', fatal=False)
88
89 return {
90 'id': video_id,
91 'display_id': display_id,
92 'url': video_url,
93 'title': title,
94 'thumbnail': thumbnail,
95 'age_limit': 18,
96 }