| 
									
										
										
										
											2015-03-04 15:02:13 -05:00
										 |  |  | from __future__ import unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from .common import InfoExtractor | 
					
						
							| 
									
										
										
										
											2015-11-21 22:18:17 +06:00
										 |  |  | from ..compat import compat_urllib_parse | 
					
						
							|  |  |  | from ..utils import ( | 
					
						
							|  |  |  |     ExtractorError, | 
					
						
							|  |  |  |     sanitized_Request, | 
					
						
							| 
									
										
										
										
											2015-03-04 15:02:13 -05:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-17 21:06:38 +06:00
										 |  |  | class PrimeShareTVIE(InfoExtractor): | 
					
						
							|  |  |  |     _VALID_URL = r'https?://(?:www\.)?primeshare\.tv/download/(?P<id>[\da-zA-Z]+)' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     _TEST = { | 
					
						
							|  |  |  |         'url': 'http://primeshare.tv/download/238790B611', | 
					
						
							|  |  |  |         'md5': 'b92d9bf5461137c36228009f31533fbc', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': '238790B611', | 
					
						
							|  |  |  |             'ext': 'mp4', | 
					
						
							|  |  |  |             'title': 'Public Domain - 1960s Commercial - Crest Toothpaste-YKsuFona', | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-03-04 15:18:06 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-04 15:02:13 -05:00
										 |  |  |     def _real_extract(self, url): | 
					
						
							|  |  |  |         video_id = self._match_id(url) | 
					
						
							| 
									
										
										
										
											2015-03-17 21:06:38 +06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-04 15:02:13 -05:00
										 |  |  |         webpage = self._download_webpage(url, video_id) | 
					
						
							| 
									
										
										
										
											2015-03-17 21:06:38 +06:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if '>File not exist<' in webpage: | 
					
						
							|  |  |  |             raise ExtractorError('Video %s does not exist' % video_id, expected=True) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-14 22:36:30 +06:00
										 |  |  |         fields = self._hidden_inputs(webpage) | 
					
						
							| 
									
										
										
										
											2015-03-17 21:06:38 +06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-04 15:02:13 -05:00
										 |  |  |         headers = { | 
					
						
							|  |  |  |             'Referer': url, | 
					
						
							|  |  |  |             'Content-Type': 'application/x-www-form-urlencoded', | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-03-17 21:06:38 +06:00
										 |  |  | 
 | 
					
						
							|  |  |  |         wait_time = int(self._search_regex( | 
					
						
							|  |  |  |             r'var\s+cWaitTime\s*=\s*(\d+)', | 
					
						
							|  |  |  |             webpage, 'wait time', default=7)) + 1 | 
					
						
							|  |  |  |         self._sleep(wait_time, video_id) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-21 22:18:17 +06:00
										 |  |  |         req = sanitized_Request( | 
					
						
							| 
									
										
										
										
											2015-03-17 21:06:38 +06:00
										 |  |  |             url, compat_urllib_parse.urlencode(fields), headers) | 
					
						
							|  |  |  |         video_page = self._download_webpage( | 
					
						
							|  |  |  |             req, video_id, 'Downloading video page') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         video_url = self._search_regex( | 
					
						
							|  |  |  |             r"url\s*:\s*'([^']+\.primeshare\.tv(?::443)?/file/[^']+)'", | 
					
						
							|  |  |  |             video_page, 'video url') | 
					
						
							| 
									
										
										
										
											2015-03-04 15:02:13 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |         title = self._html_search_regex( | 
					
						
							| 
									
										
										
										
											2015-03-17 21:06:38 +06:00
										 |  |  |             r'<h1>Watch\s*(?: )?\s*\((.+?)(?:\s*\[\.\.\.\])?\)\s*(?: )?\s*<strong>', | 
					
						
							|  |  |  |             video_page, 'title') | 
					
						
							| 
									
										
										
										
											2015-03-04 15:02:13 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return { | 
					
						
							|  |  |  |             'id': video_id, | 
					
						
							|  |  |  |             'url': video_url, | 
					
						
							|  |  |  |             'title': title, | 
					
						
							|  |  |  |             'ext': 'mp4', | 
					
						
							|  |  |  |         } |