| 
									
										
										
										
											2016-05-27 13:37:40 +02:00
										 |  |  | from __future__ import unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from .common import InfoExtractor | 
					
						
							|  |  |  | from .ooyala import OoyalaIE | 
					
						
							| 
									
										
										
										
											2016-06-09 21:29:41 +07:00
										 |  |  | from ..utils import js_to_json | 
					
						
							| 
									
										
										
										
											2016-05-27 13:37:40 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class GodTVIE(InfoExtractor): | 
					
						
							| 
									
										
										
										
											2016-06-09 21:34:47 +07:00
										 |  |  |     _VALID_URL = r'https?://(?:www\.)?god\.tv(?:/[^/]+)*/(?P<id>[^/?#&]+)' | 
					
						
							| 
									
										
										
										
											2016-06-09 21:29:41 +07:00
										 |  |  |     _TESTS = [{ | 
					
						
							| 
									
										
										
										
											2016-05-27 13:37:40 +02:00
										 |  |  |         'url': 'http://god.tv/jesus-image/video/jesus-conference-2016/randy-needham', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': 'lpd3g2MzE6D1g8zFAKz8AGpxWcpu6o_3', | 
					
						
							|  |  |  |             'ext': 'mp4', | 
					
						
							|  |  |  |             'title': 'Randy Needham', | 
					
						
							|  |  |  |             'duration': 3615.08, | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         'params': { | 
					
						
							|  |  |  |             'skip_download': True, | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2016-06-09 21:29:41 +07:00
										 |  |  |     }, { | 
					
						
							|  |  |  |         'url': 'http://god.tv/playlist/bible-study', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': 'bible-study', | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         'playlist_mincount': 37, | 
					
						
							| 
									
										
										
										
											2016-06-09 21:33:51 +07:00
										 |  |  |     }, { | 
					
						
							|  |  |  |         'url': 'http://god.tv/node/15097', | 
					
						
							|  |  |  |         'only_matching': True, | 
					
						
							|  |  |  |     }, { | 
					
						
							|  |  |  |         'url': 'http://god.tv/live/africa', | 
					
						
							|  |  |  |         'only_matching': True, | 
					
						
							| 
									
										
										
										
											2016-06-09 21:34:47 +07:00
										 |  |  |     }, { | 
					
						
							|  |  |  |         'url': 'http://god.tv/liveevents', | 
					
						
							|  |  |  |         'only_matching': True, | 
					
						
							| 
									
										
										
										
											2016-06-09 21:29:41 +07:00
										 |  |  |     }] | 
					
						
							| 
									
										
										
										
											2016-05-27 13:37:40 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							|  |  |  |         display_id = self._match_id(url) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         webpage = self._download_webpage(url, display_id) | 
					
						
							| 
									
										
										
										
											2016-06-09 21:29:41 +07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         settings = self._parse_json( | 
					
						
							|  |  |  |             self._search_regex( | 
					
						
							|  |  |  |                 r'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);', | 
					
						
							|  |  |  |                 webpage, 'settings', default='{}'), | 
					
						
							|  |  |  |             display_id, transform_source=js_to_json, fatal=False) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ooyala_id = None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if settings: | 
					
						
							|  |  |  |             playlist = settings.get('playlist') | 
					
						
							|  |  |  |             if playlist and isinstance(playlist, list): | 
					
						
							|  |  |  |                 entries = [ | 
					
						
							|  |  |  |                     OoyalaIE._build_url_result(video['content_id']) | 
					
						
							|  |  |  |                     for video in playlist if video.get('content_id')] | 
					
						
							|  |  |  |                 if entries: | 
					
						
							|  |  |  |                     return self.playlist_result(entries, display_id) | 
					
						
							|  |  |  |             ooyala_id = settings.get('ooyala', {}).get('content_id') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if not ooyala_id: | 
					
						
							|  |  |  |             ooyala_id = self._search_regex( | 
					
						
							|  |  |  |                 r'["\']content_id["\']\s*:\s*(["\'])(?P<id>[\w-]+)\1', | 
					
						
							|  |  |  |                 webpage, 'ooyala id', group='id') | 
					
						
							| 
									
										
										
										
											2016-05-27 13:37:40 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return OoyalaIE._build_url_result(ooyala_id) |