| 
									
										
										
										
											2014-06-10 19:37:38 +07:00
										 |  |  | from __future__ import unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-09 19:39:41 +01:00
										 |  |  | from .common import InfoExtractor | 
					
						
							| 
									
										
										
										
											2014-06-10 19:37:38 +07:00
										 |  |  | from ..utils import ( | 
					
						
							|  |  |  |     int_or_none, | 
					
						
							| 
									
										
										
										
											2016-05-19 04:34:19 +06:00
										 |  |  |     remove_end, | 
					
						
							|  |  |  |     unified_strdate, | 
					
						
							| 
									
										
										
										
											2014-06-10 19:37:38 +07:00
										 |  |  | ) | 
					
						
							| 
									
										
										
										
											2013-12-09 19:39:41 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class NDTVIE(InfoExtractor): | 
					
						
							| 
									
										
										
										
											2016-05-19 04:34:19 +06:00
										 |  |  |     _VALID_URL = r'https?://(?:www\.)?ndtv\.com/video/(?:[^/]+/)+[^/?^&]+-(?P<id>\d+)' | 
					
						
							| 
									
										
										
										
											2013-12-09 19:39:41 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     _TEST = { | 
					
						
							| 
									
										
										
										
											2016-05-19 04:34:19 +06:00
										 |  |  |         'url': 'http://www.ndtv.com/video/news/news/ndtv-exclusive-don-t-need-character-certificate-from-rahul-gandhi-says-arvind-kejriwal-300710', | 
					
						
							| 
									
										
										
										
											2014-06-10 19:37:38 +07:00
										 |  |  |         'md5': '39f992dbe5fb531c395d8bbedb1e5e88', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': '300710', | 
					
						
							|  |  |  |             'ext': 'mp4', | 
					
						
							|  |  |  |             'title': "NDTV exclusive: Don't need character certificate from Rahul Gandhi, says Arvind Kejriwal", | 
					
						
							|  |  |  |             'description': 'md5:ab2d4b4a6056c5cb4caa6d729deabf02', | 
					
						
							|  |  |  |             'upload_date': '20131208', | 
					
						
							|  |  |  |             'duration': 1327, | 
					
						
							| 
									
										
										
										
											2017-01-02 20:08:07 +08:00
										 |  |  |             'thumbnail': r're:https?://.*\.jpg', | 
					
						
							| 
									
										
										
										
											2013-12-09 19:39:41 +01:00
										 |  |  |         }, | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							| 
									
										
										
										
											2015-01-19 10:10:05 +01:00
										 |  |  |         video_id = self._match_id(url) | 
					
						
							| 
									
										
										
										
											2013-12-09 19:39:41 +01:00
										 |  |  |         webpage = self._download_webpage(url, video_id) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-19 04:34:19 +06:00
										 |  |  |         title = remove_end(self._og_search_title(webpage), ' - NDTV') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-09 19:39:41 +01:00
										 |  |  |         filename = self._search_regex( | 
					
						
							| 
									
										
										
										
											2014-06-10 19:37:38 +07:00
										 |  |  |             r"__filename='([^']+)'", webpage, 'video filename') | 
					
						
							| 
									
										
										
										
											2016-05-19 04:34:19 +06:00
										 |  |  |         video_url = 'http://bitcast-b.bitgravity.com/ndtvod/23372/ndtv/%s' % filename | 
					
						
							| 
									
										
										
										
											2013-12-09 19:39:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-10 19:37:38 +07:00
										 |  |  |         duration = int_or_none(self._search_regex( | 
					
						
							|  |  |  |             r"__duration='([^']+)'", webpage, 'duration', fatal=False)) | 
					
						
							| 
									
										
										
										
											2013-12-09 19:39:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-19 04:34:19 +06:00
										 |  |  |         upload_date = unified_strdate(self._html_search_meta( | 
					
						
							|  |  |  |             'publish-date', webpage, 'upload date', fatal=False)) | 
					
						
							| 
									
										
										
										
											2013-12-09 19:39:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-19 04:34:19 +06:00
										 |  |  |         description = remove_end(self._og_search_description(webpage), ' (Read more)') | 
					
						
							| 
									
										
										
										
											2014-06-10 19:37:38 +07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-09 19:39:41 +01:00
										 |  |  |         return { | 
					
						
							|  |  |  |             'id': video_id, | 
					
						
							|  |  |  |             'url': video_url, | 
					
						
							| 
									
										
										
										
											2014-06-10 19:37:38 +07:00
										 |  |  |             'title': title, | 
					
						
							| 
									
										
										
										
											2013-12-09 19:39:41 +01:00
										 |  |  |             'description': description, | 
					
						
							|  |  |  |             'thumbnail': self._og_search_thumbnail(webpage), | 
					
						
							|  |  |  |             'duration': duration, | 
					
						
							|  |  |  |             'upload_date': upload_date, | 
					
						
							|  |  |  |         } |