| 
									
										
										
										
											2015-03-12 21:56:56 +06:00
										 |  |  | # coding: utf-8 | 
					
						
							|  |  |  | from __future__ import unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from .common import InfoExtractor | 
					
						
							| 
									
										
										
										
											2016-10-11 17:46:13 +08:00
										 |  |  | from .streamable import StreamableIE | 
					
						
							| 
									
										
										
										
											2015-03-12 21:56:56 +06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class FootyRoomIE(InfoExtractor): | 
					
						
							| 
									
										
										
										
											2016-10-11 17:46:13 +08:00
										 |  |  |     _VALID_URL = r'https?://footyroom\.com/matches/(?P<id>\d+)' | 
					
						
							| 
									
										
										
										
											2015-04-12 11:23:01 +02:00
										 |  |  |     _TESTS = [{ | 
					
						
							| 
									
										
										
										
											2016-10-11 17:46:13 +08:00
										 |  |  |         'url': 'http://footyroom.com/matches/79922154/hull-city-vs-chelsea/review', | 
					
						
							| 
									
										
										
										
											2015-03-12 21:56:56 +06:00
										 |  |  |         'info_dict': { | 
					
						
							| 
									
										
										
										
											2016-10-11 17:46:13 +08:00
										 |  |  |             'id': '79922154', | 
					
						
							|  |  |  |             'title': 'VIDEO Hull City 0 - 2 Chelsea', | 
					
						
							| 
									
										
										
										
											2015-03-12 21:56:56 +06:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2016-10-11 17:46:13 +08:00
										 |  |  |         'playlist_count': 2, | 
					
						
							|  |  |  |         'add_ie': [StreamableIE.ie_key()], | 
					
						
							| 
									
										
										
										
											2015-04-12 17:11:11 +06:00
										 |  |  |     }, { | 
					
						
							| 
									
										
										
										
											2016-10-11 17:46:13 +08:00
										 |  |  |         'url': 'http://footyroom.com/matches/75817984/georgia-vs-germany/review', | 
					
						
							| 
									
										
										
										
											2015-04-12 11:23:01 +02:00
										 |  |  |         'info_dict': { | 
					
						
							| 
									
										
										
										
											2016-10-11 17:46:13 +08:00
										 |  |  |             'id': '75817984', | 
					
						
							|  |  |  |             'title': 'VIDEO Georgia 0 - 2 Germany', | 
					
						
							| 
									
										
										
										
											2015-04-12 11:23:01 +02:00
										 |  |  |         }, | 
					
						
							|  |  |  |         'playlist_count': 1, | 
					
						
							| 
									
										
										
										
											2016-10-11 17:46:13 +08:00
										 |  |  |         'add_ie': ['Playwire'] | 
					
						
							| 
									
										
										
										
											2015-04-12 17:11:11 +06:00
										 |  |  |     }] | 
					
						
							| 
									
										
										
										
											2015-03-12 21:56:56 +06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							|  |  |  |         playlist_id = self._match_id(url) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         webpage = self._download_webpage(url, playlist_id) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 17:46:13 +08:00
										 |  |  |         playlist = self._parse_json(self._search_regex( | 
					
						
							|  |  |  |             r'DataStore\.media\s*=\s*([^;]+)', webpage, 'media data'), | 
					
						
							| 
									
										
										
										
											2015-03-12 21:56:56 +06:00
										 |  |  |             playlist_id) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         playlist_title = self._og_search_title(webpage) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         entries = [] | 
					
						
							|  |  |  |         for video in playlist: | 
					
						
							|  |  |  |             payload = video.get('payload') | 
					
						
							|  |  |  |             if not payload: | 
					
						
							|  |  |  |                 continue | 
					
						
							| 
									
										
										
										
											2016-10-11 17:46:13 +08:00
										 |  |  |             playwire_url = self._html_search_regex( | 
					
						
							| 
									
										
										
										
											2015-03-12 21:56:56 +06:00
										 |  |  |                 r'data-config="([^"]+)"', payload, | 
					
						
							|  |  |  |                 'playwire url', default=None) | 
					
						
							|  |  |  |             if playwire_url: | 
					
						
							| 
									
										
										
										
											2015-04-12 17:09:52 +06:00
										 |  |  |                 entries.append(self.url_result(self._proto_relative_url( | 
					
						
							|  |  |  |                     playwire_url, 'http:'), 'Playwire')) | 
					
						
							| 
									
										
										
										
											2015-03-12 21:56:56 +06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 17:46:13 +08:00
										 |  |  |             streamable_url = StreamableIE._extract_url(payload) | 
					
						
							|  |  |  |             if streamable_url: | 
					
						
							|  |  |  |                 entries.append(self.url_result( | 
					
						
							|  |  |  |                     streamable_url, StreamableIE.ie_key())) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-12 21:56:56 +06:00
										 |  |  |         return self.playlist_result(entries, playlist_id, playlist_title) |