]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/eroprofile.py
[dailymotion] Error spelling
[youtube-dl] / 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             self.raise_login_required('This video requires login')
75
76         video_id = self._search_regex(
77             [r"glbUpdViews\s*\('\d*','(\d+)'", r'p/report/video/(\d+)'],
78             webpage, 'video id', default=None)
79
80         video_url = unescapeHTML(self._search_regex(
81             r'<source src="([^"]+)', webpage, 'video url'))
82         title = self._html_search_regex(
83             r'Title:</th><td>([^<]+)</td>', webpage, 'title')
84         thumbnail = self._search_regex(
85             r'onclick="showVideoPlayer\(\)"><img src="([^"]+)',
86             webpage, 'thumbnail', fatal=False)
87
88         return {
89             'id': video_id,
90             'display_id': display_id,
91             'url': video_url,
92             'title': title,
93             'thumbnail': thumbnail,
94             'age_limit': 18,
95         }