| 
									
										
										
										
											2014-11-26 13:01:39 +01:00
										 |  |  | from __future__ import unicode_literals | 
					
						
							| 
									
										
										
										
											2013-08-03 22:50:27 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | from .common import InfoExtractor | 
					
						
							|  |  |  | from ..utils import ( | 
					
						
							|  |  |  |     find_xpath_attr, | 
					
						
							| 
									
										
										
										
											2014-11-26 13:01:39 +01:00
										 |  |  |     int_or_none, | 
					
						
							| 
									
										
										
										
											2013-08-03 22:50:27 +02:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-23 20:41:03 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-03 22:50:27 +02:00
										 |  |  | class VideofyMeIE(InfoExtractor): | 
					
						
							| 
									
										
										
										
											2014-11-26 13:01:39 +01:00
										 |  |  |     _VALID_URL = r'https?://(?:www\.videofy\.me/.+?|p\.videofy\.me/v)/(?P<id>\d+)(&|#|$)' | 
					
						
							|  |  |  |     IE_NAME = 'videofy.me' | 
					
						
							| 
									
										
										
										
											2013-08-03 22:50:27 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     _TEST = { | 
					
						
							| 
									
										
										
										
											2014-11-26 13:01:39 +01:00
										 |  |  |         'url': 'http://www.videofy.me/thisisvideofyme/1100701', | 
					
						
							|  |  |  |         'md5': 'c77d700bdc16ae2e9f3c26019bd96143', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': '1100701', | 
					
						
							|  |  |  |             'ext': 'mp4', | 
					
						
							|  |  |  |             'title': 'This is VideofyMe', | 
					
						
							|  |  |  |             'description': None, | 
					
						
							|  |  |  |             'uploader': 'VideofyMe', | 
					
						
							|  |  |  |             'uploader_id': 'thisisvideofyme', | 
					
						
							|  |  |  |             'view_count': int, | 
					
						
							| 
									
										
										
										
											2013-08-03 22:50:27 +02:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2014-11-23 20:41:03 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-03 22:50:27 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							| 
									
										
										
										
											2014-11-26 13:01:39 +01:00
										 |  |  |         video_id = self._match_id(url) | 
					
						
							| 
									
										
										
										
											2013-11-26 18:48:52 +01:00
										 |  |  |         config = self._download_xml('http://sunshine.videofy.me/?videoId=%s' % video_id, | 
					
						
							| 
									
										
										
										
											2014-11-23 21:39:15 +01:00
										 |  |  |                                     video_id) | 
					
						
							| 
									
										
										
										
											2013-08-03 22:50:27 +02:00
										 |  |  |         video = config.find('video') | 
					
						
							|  |  |  |         sources = video.find('sources') | 
					
						
							| 
									
										
										
										
											2014-11-23 20:41:03 +01:00
										 |  |  |         url_node = next(node for node in [find_xpath_attr(sources, 'source', 'id', 'HQ %s' % key) | 
					
						
							| 
									
										
										
										
											2014-11-23 21:39:15 +01:00
										 |  |  |                                           for key in ['on', 'av', 'off']] if node is not None) | 
					
						
							| 
									
										
										
										
											2013-08-03 22:50:27 +02:00
										 |  |  |         video_url = url_node.find('url').text | 
					
						
							| 
									
										
										
										
											2014-11-26 13:01:39 +01:00
										 |  |  |         view_count = int_or_none(self._search_regex( | 
					
						
							|  |  |  |             r'([0-9]+)', video.find('views').text, 'view count', fatal=False)) | 
					
						
							| 
									
										
										
										
											2013-08-03 22:50:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-26 13:01:39 +01:00
										 |  |  |         return { | 
					
						
							|  |  |  |             'id': video_id, | 
					
						
							|  |  |  |             'title': video.find('title').text, | 
					
						
							|  |  |  |             'url': video_url, | 
					
						
							|  |  |  |             'thumbnail': video.find('thumb').text, | 
					
						
							|  |  |  |             'description': video.find('description').text, | 
					
						
							|  |  |  |             'uploader': config.find('blog/name').text, | 
					
						
							|  |  |  |             'uploader_id': video.find('identifier').text, | 
					
						
							|  |  |  |             'view_count': view_count, | 
					
						
							|  |  |  |         } |