| 
									
										
										
										
											2014-12-09 22:29:01 +06:00
										 |  |  | from __future__ import unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-18 12:17:24 +08:00
										 |  |  | from .mtv import MTVServicesInfoExtractor | 
					
						
							|  |  |  | from ..utils import unified_strdate | 
					
						
							| 
									
										
										
										
											2014-12-09 22:29:01 +06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-18 12:17:24 +08:00
										 |  |  | class BetIE(MTVServicesInfoExtractor): | 
					
						
							| 
									
										
										
										
											2014-12-09 22:29:01 +06:00
										 |  |  |     _VALID_URL = r'https?://(?:www\.)?bet\.com/(?:[^/]+/)+(?P<id>.+?)\.html' | 
					
						
							|  |  |  |     _TESTS = [ | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             'url': 'http://www.bet.com/news/politics/2014/12/08/in-bet-exclusive-obama-talks-race-and-racism.html', | 
					
						
							|  |  |  |             'info_dict': { | 
					
						
							| 
									
										
										
										
											2016-06-18 12:17:24 +08:00
										 |  |  |                 'id': '07e96bd3-8850-3051-b856-271b457f0ab8', | 
					
						
							| 
									
										
										
										
											2014-12-09 22:29:01 +06:00
										 |  |  |                 'display_id': 'in-bet-exclusive-obama-talks-race-and-racism', | 
					
						
							|  |  |  |                 'ext': 'flv', | 
					
						
							| 
									
										
										
										
											2015-05-07 16:56:15 +01:00
										 |  |  |                 'title': 'A Conversation With President Obama', | 
					
						
							| 
									
										
										
										
											2016-06-18 12:17:24 +08:00
										 |  |  |                 'description': 'President Obama urges persistence in confronting racism and bias.', | 
					
						
							| 
									
										
										
										
											2014-12-09 22:29:01 +06:00
										 |  |  |                 'duration': 1534, | 
					
						
							|  |  |  |                 'upload_date': '20141208', | 
					
						
							| 
									
										
										
										
											2017-01-02 20:08:07 +08:00
										 |  |  |                 'thumbnail': r're:(?i)^https?://.*\.jpg$', | 
					
						
							| 
									
										
										
										
											2016-06-18 12:17:24 +08:00
										 |  |  |                 'subtitles': { | 
					
						
							|  |  |  |                     'en': 'mincount:2', | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2014-12-09 22:29:01 +06:00
										 |  |  |             }, | 
					
						
							|  |  |  |             'params': { | 
					
						
							|  |  |  |                 # rtmp download | 
					
						
							|  |  |  |                 'skip_download': True, | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             'url': 'http://www.bet.com/video/news/national/2014/justice-for-ferguson-a-community-reacts.html', | 
					
						
							|  |  |  |             'info_dict': { | 
					
						
							| 
									
										
										
										
											2016-06-18 12:17:24 +08:00
										 |  |  |                 'id': '9f516bf1-7543-39c4-8076-dd441b459ba9', | 
					
						
							| 
									
										
										
										
											2014-12-09 22:29:01 +06:00
										 |  |  |                 'display_id': 'justice-for-ferguson-a-community-reacts', | 
					
						
							|  |  |  |                 'ext': 'flv', | 
					
						
							|  |  |  |                 'title': 'Justice for Ferguson: A Community Reacts', | 
					
						
							|  |  |  |                 'description': 'A BET News special.', | 
					
						
							|  |  |  |                 'duration': 1696, | 
					
						
							|  |  |  |                 'upload_date': '20141125', | 
					
						
							| 
									
										
										
										
											2017-01-02 20:08:07 +08:00
										 |  |  |                 'thumbnail': r're:(?i)^https?://.*\.jpg$', | 
					
						
							| 
									
										
										
										
											2016-06-18 12:17:24 +08:00
										 |  |  |                 'subtitles': { | 
					
						
							|  |  |  |                     'en': 'mincount:2', | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2014-12-09 22:29:01 +06:00
										 |  |  |             }, | 
					
						
							|  |  |  |             'params': { | 
					
						
							|  |  |  |                 # rtmp download | 
					
						
							|  |  |  |                 'skip_download': True, | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-18 12:17:24 +08:00
										 |  |  |     _FEED_URL = "http://feeds.mtvnservices.com/od/feed/bet-mrss-player" | 
					
						
							| 
									
										
										
										
											2014-12-09 22:29:01 +06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-18 12:17:24 +08:00
										 |  |  |     def _get_feed_query(self, uri): | 
					
						
							| 
									
										
										
										
											2016-08-24 23:58:22 +08:00
										 |  |  |         return { | 
					
						
							| 
									
										
										
										
											2016-06-18 12:17:24 +08:00
										 |  |  |             'uuid': uri, | 
					
						
							| 
									
										
										
										
											2016-08-24 23:58:22 +08:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-05-07 16:56:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-18 12:17:24 +08:00
										 |  |  |     def _extract_mgid(self, webpage): | 
					
						
							|  |  |  |         return self._search_regex(r'data-uri="([^"]+)', webpage, 'mgid') | 
					
						
							| 
									
										
										
										
											2014-12-09 22:29:01 +06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-18 12:17:24 +08:00
										 |  |  |     def _real_extract(self, url): | 
					
						
							|  |  |  |         display_id = self._match_id(url) | 
					
						
							| 
									
										
										
										
											2014-12-09 22:29:01 +06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-18 12:17:24 +08:00
										 |  |  |         webpage = self._download_webpage(url, display_id) | 
					
						
							|  |  |  |         mgid = self._extract_mgid(webpage) | 
					
						
							|  |  |  |         videos_info = self._get_videos_info(mgid) | 
					
						
							| 
									
										
										
										
											2014-12-09 22:29:01 +06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-18 12:17:24 +08:00
										 |  |  |         info_dict = videos_info['entries'][0] | 
					
						
							| 
									
										
										
										
											2014-12-09 22:29:01 +06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-18 12:17:24 +08:00
										 |  |  |         upload_date = unified_strdate(self._html_search_meta('date', webpage)) | 
					
						
							|  |  |  |         description = self._html_search_meta('description', webpage) | 
					
						
							| 
									
										
										
										
											2014-12-09 22:29:01 +06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-18 12:17:24 +08:00
										 |  |  |         info_dict.update({ | 
					
						
							| 
									
										
										
										
											2014-12-09 22:29:01 +06:00
										 |  |  |             'display_id': display_id, | 
					
						
							|  |  |  |             'description': description, | 
					
						
							| 
									
										
										
										
											2016-06-18 12:17:24 +08:00
										 |  |  |             'upload_date': upload_date, | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return info_dict |