| 
									
										
										
										
											2016-10-02 13:39:18 +02:00
										 |  |  | # coding: utf-8 | 
					
						
							| 
									
										
										
										
											2014-02-14 18:14:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | from __future__ import unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from .common import InfoExtractor | 
					
						
							| 
									
										
										
										
											2014-12-12 13:03:16 +01:00
										 |  |  | from ..utils import js_to_json | 
					
						
							| 
									
										
										
										
											2014-02-14 18:14:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class HelsinkiIE(InfoExtractor): | 
					
						
							| 
									
										
										
										
											2014-02-17 11:32:30 +01:00
										 |  |  |     IE_DESC = 'helsinki.fi' | 
					
						
							| 
									
										
										
										
											2014-02-14 18:14:28 +02:00
										 |  |  |     _VALID_URL = r'https?://video\.helsinki\.fi/Arkisto/flash\.php\?id=(?P<id>\d+)' | 
					
						
							|  |  |  |     _TEST = { | 
					
						
							|  |  |  |         'url': 'http://video.helsinki.fi/Arkisto/flash.php?id=20258', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': '20258', | 
					
						
							|  |  |  |             'ext': 'mp4', | 
					
						
							|  |  |  |             'title': 'Tietotekniikkafoorumi-iltapäivä', | 
					
						
							| 
									
										
										
										
											2014-02-17 11:32:30 +01:00
										 |  |  |             'description': 'md5:f5c904224d43c133225130fe156a5ee0', | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         'params': { | 
					
						
							|  |  |  |             'skip_download': True,  # RTMP | 
					
						
							| 
									
										
										
										
											2014-02-14 18:14:28 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							| 
									
										
										
										
											2014-12-12 13:03:16 +01:00
										 |  |  |         video_id = self._match_id(url) | 
					
						
							| 
									
										
										
										
											2014-02-17 11:32:30 +01:00
										 |  |  |         webpage = self._download_webpage(url, video_id) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-12 13:03:16 +01:00
										 |  |  |         params = self._parse_json(self._html_search_regex( | 
					
						
							|  |  |  |             r'(?s)jwplayer\("player"\).setup\((\{.*?\})\);', | 
					
						
							|  |  |  |             webpage, 'player code'), video_id, transform_source=js_to_json) | 
					
						
							|  |  |  |         formats = [{ | 
					
						
							|  |  |  |             'url': s['file'], | 
					
						
							|  |  |  |             'ext': 'mp4', | 
					
						
							|  |  |  |         } for s in params['sources']] | 
					
						
							| 
									
										
										
										
											2014-02-17 11:32:30 +01:00
										 |  |  |         self._sort_formats(formats) | 
					
						
							| 
									
										
										
										
											2014-02-14 18:14:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return { | 
					
						
							| 
									
										
										
										
											2014-02-17 11:32:30 +01:00
										 |  |  |             'id': video_id, | 
					
						
							| 
									
										
										
										
											2014-02-14 18:14:28 +02:00
										 |  |  |             'title': self._og_search_title(webpage).replace('Video: ', ''), | 
					
						
							|  |  |  |             'description': self._og_search_description(webpage), | 
					
						
							| 
									
										
										
										
											2014-02-17 11:32:30 +01:00
										 |  |  |             'formats': formats, | 
					
						
							| 
									
										
										
										
											2014-02-14 18:14:28 +02:00
										 |  |  |         } |