| 
									
										
										
										
											2014-12-26 17:15:34 +01:00
										 |  |  | from __future__ import unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-26 23:24:15 +02:00
										 |  |  | import re | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-26 17:15:34 +01:00
										 |  |  | from .common import InfoExtractor | 
					
						
							| 
									
										
										
										
											2015-03-26 23:24:15 +02:00
										 |  |  | from ..compat import compat_urllib_parse | 
					
						
							| 
									
										
										
										
											2015-05-09 21:19:09 +06:00
										 |  |  | from ..utils import ( | 
					
						
							|  |  |  |     ExtractorError, | 
					
						
							|  |  |  |     unescapeHTML | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2014-12-26 17:15:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-26 23:32:41 +06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-26 17:15:34 +01:00
										 |  |  | class EroProfileIE(InfoExtractor): | 
					
						
							| 
									
										
										
										
											2014-12-26 23:32:41 +06:00
										 |  |  |     _VALID_URL = r'https?://(?:www\.)?eroprofile\.com/m/videos/view/(?P<id>[^/]+)' | 
					
						
							| 
									
										
										
										
											2015-03-26 23:24:15 +02:00
										 |  |  |     _LOGIN_URL = 'http://www.eroprofile.com/auth/auth.php?' | 
					
						
							|  |  |  |     _NETRC_MACHINE = 'eroprofile' | 
					
						
							|  |  |  |     _TESTS = [{ | 
					
						
							| 
									
										
										
										
											2014-12-26 17:15:34 +01:00
										 |  |  |         'url': 'http://www.eroprofile.com/m/videos/view/sexy-babe-softcore', | 
					
						
							|  |  |  |         'md5': 'c26f351332edf23e1ea28ce9ec9de32f', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': '3733775', | 
					
						
							| 
									
										
										
										
											2014-12-26 23:32:41 +06:00
										 |  |  |             'display_id': 'sexy-babe-softcore', | 
					
						
							| 
									
										
										
										
											2014-12-26 17:15:34 +01:00
										 |  |  |             'ext': 'm4v', | 
					
						
							| 
									
										
										
										
											2014-12-26 23:32:41 +06:00
										 |  |  |             'title': 'sexy babe softcore', | 
					
						
							| 
									
										
										
										
											2014-12-26 17:15:34 +01:00
										 |  |  |             'thumbnail': 're:https?://.*\.jpg', | 
					
						
							|  |  |  |             'age_limit': 18, | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-03-26 23:24:15 +02:00
										 |  |  |     }, { | 
					
						
							|  |  |  |         'url': 'http://www.eroprofile.com/m/videos/view/Try-It-On-Pee_cut_2-wmv-4shared-com-file-sharing-download-movie-file', | 
					
						
							|  |  |  |         'md5': '1baa9602ede46ce904c431f5418d8916', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': '1133519', | 
					
						
							|  |  |  |             'ext': 'm4v', | 
					
						
							|  |  |  |             'title': 'Try It On Pee_cut_2.wmv - 4shared.com - file sharing - download movie file', | 
					
						
							|  |  |  |             'thumbnail': 're:https?://.*\.jpg', | 
					
						
							|  |  |  |             'age_limit': 18, | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         'skip': 'Requires login', | 
					
						
							|  |  |  |     }] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _login(self): | 
					
						
							|  |  |  |         (username, password) = self._get_login_info() | 
					
						
							|  |  |  |         if username is None: | 
					
						
							|  |  |  |             return | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         query = compat_urllib_parse.urlencode({ | 
					
						
							|  |  |  |             'username': username, | 
					
						
							|  |  |  |             'password': password, | 
					
						
							|  |  |  |             'url': 'http://www.eroprofile.com/', | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  |         login_url = self._LOGIN_URL + query | 
					
						
							|  |  |  |         login_page = self._download_webpage(login_url, None, False) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         m = re.search(r'Your username or password was incorrect\.', login_page) | 
					
						
							|  |  |  |         if m: | 
					
						
							|  |  |  |             raise ExtractorError( | 
					
						
							|  |  |  |                 'Wrong username and/or password.', expected=True) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         self.report_login() | 
					
						
							|  |  |  |         redirect_url = self._search_regex( | 
					
						
							|  |  |  |             r'<script[^>]+?src="([^"]+)"', login_page, 'login redirect url') | 
					
						
							|  |  |  |         self._download_webpage(redirect_url, None, False) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _real_initialize(self): | 
					
						
							|  |  |  |         self._login() | 
					
						
							| 
									
										
										
										
											2014-12-26 17:15:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							| 
									
										
										
										
											2014-12-26 23:32:41 +06:00
										 |  |  |         display_id = self._match_id(url) | 
					
						
							| 
									
										
										
										
											2014-12-26 17:15:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-26 23:32:41 +06:00
										 |  |  |         webpage = self._download_webpage(url, display_id) | 
					
						
							| 
									
										
										
										
											2014-12-26 17:15:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-26 23:24:15 +02:00
										 |  |  |         m = re.search(r'You must be logged in to view this video\.', webpage) | 
					
						
							|  |  |  |         if m: | 
					
						
							| 
									
										
										
										
											2015-08-26 21:25:37 +06:00
										 |  |  |             self.raise_login_required('This video requires login') | 
					
						
							| 
									
										
										
										
											2015-03-26 23:24:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-26 23:32:41 +06:00
										 |  |  |         video_id = self._search_regex( | 
					
						
							|  |  |  |             [r"glbUpdViews\s*\('\d*','(\d+)'", r'p/report/video/(\d+)'], | 
					
						
							|  |  |  |             webpage, 'video id', default=None) | 
					
						
							| 
									
										
										
										
											2014-12-26 17:15:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-09 21:19:09 +06:00
										 |  |  |         video_url = unescapeHTML(self._search_regex( | 
					
						
							|  |  |  |             r'<source src="([^"]+)', webpage, 'video url')) | 
					
						
							| 
									
										
										
										
											2014-12-26 17:15:34 +01:00
										 |  |  |         title = self._html_search_regex( | 
					
						
							| 
									
										
										
										
											2014-12-26 23:32:41 +06:00
										 |  |  |             r'Title:</th><td>([^<]+)</td>', webpage, 'title') | 
					
						
							|  |  |  |         thumbnail = self._search_regex( | 
					
						
							|  |  |  |             r'onclick="showVideoPlayer\(\)"><img src="([^"]+)', | 
					
						
							|  |  |  |             webpage, 'thumbnail', fatal=False) | 
					
						
							| 
									
										
										
										
											2014-12-26 17:15:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return { | 
					
						
							|  |  |  |             'id': video_id, | 
					
						
							| 
									
										
										
										
											2014-12-26 23:32:41 +06:00
										 |  |  |             'display_id': display_id, | 
					
						
							| 
									
										
										
										
											2014-12-26 17:15:34 +01:00
										 |  |  |             'url': video_url, | 
					
						
							|  |  |  |             'title': title, | 
					
						
							|  |  |  |             'thumbnail': thumbnail, | 
					
						
							|  |  |  |             'age_limit': 18, | 
					
						
							|  |  |  |         } |