| 
									
										
										
										
											2015-05-24 20:04:13 +06:00
										 |  |  | # coding: utf-8 | 
					
						
							| 
									
										
										
										
											2015-05-16 19:50:58 -05:00
										 |  |  | from __future__ import unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from .common import InfoExtractor | 
					
						
							| 
									
										
										
										
											2015-05-24 20:04:13 +06:00
										 |  |  | from ..compat import compat_urlparse | 
					
						
							|  |  |  | from ..utils import ( | 
					
						
							|  |  |  |     fix_xml_ampersands, | 
					
						
							|  |  |  |     float_or_none, | 
					
						
							|  |  |  |     xpath_with_ns, | 
					
						
							|  |  |  |     xpath_text, | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2015-05-16 19:50:58 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class KarriereVideosIE(InfoExtractor): | 
					
						
							| 
									
										
										
										
											2015-05-24 20:04:13 +06:00
										 |  |  |     _VALID_URL = r'http://(?:www\.)?karrierevideos\.at(?:/[^/]+)+/(?P<id>[^/]+)' | 
					
						
							|  |  |  |     _TESTS = [{ | 
					
						
							| 
									
										
										
										
											2015-05-16 19:50:58 -05:00
										 |  |  |         'url': 'http://www.karrierevideos.at/berufsvideos/mittlere-hoehere-schulen/altenpflegerin', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							| 
									
										
										
										
											2015-05-24 20:04:13 +06:00
										 |  |  |             'id': '32c91', | 
					
						
							|  |  |  |             'ext': 'flv', | 
					
						
							| 
									
										
										
										
											2015-05-16 19:50:58 -05:00
										 |  |  |             'title': 'AltenpflegerIn', | 
					
						
							| 
									
										
										
										
											2015-05-24 20:04:13 +06:00
										 |  |  |             'description': 'md5:dbadd1259fde2159a9b28667cb664ae2', | 
					
						
							|  |  |  |             'thumbnail': 're:^http://.*\.png', | 
					
						
							| 
									
										
										
										
											2015-05-16 19:50:58 -05:00
										 |  |  |         }, | 
					
						
							|  |  |  |         'params': { | 
					
						
							| 
									
										
										
										
											2015-05-24 20:04:13 +06:00
										 |  |  |             # rtmp download | 
					
						
							|  |  |  |             'skip_download': True, | 
					
						
							| 
									
										
										
										
											2015-05-16 19:50:58 -05:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-05-24 20:04:13 +06:00
										 |  |  |     }, { | 
					
						
							|  |  |  |         # broken ampersands | 
					
						
							|  |  |  |         'url': 'http://www.karrierevideos.at/orientierung/vaeterkarenz-und-neue-chancen-fuer-muetter-baby-was-nun', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': '5sniu', | 
					
						
							|  |  |  |             'ext': 'flv', | 
					
						
							|  |  |  |             'title': 'Väterkarenz und neue Chancen für Mütter - "Baby - was nun?"', | 
					
						
							|  |  |  |             'description': 'md5:97092c6ad1fd7d38e9d6a5fdeb2bcc33', | 
					
						
							|  |  |  |             'thumbnail': 're:^http://.*\.png', | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         'params': { | 
					
						
							|  |  |  |             # rtmp download | 
					
						
							|  |  |  |             'skip_download': True, | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }] | 
					
						
							| 
									
										
										
										
											2015-05-16 19:50:58 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							|  |  |  |         video_id = self._match_id(url) | 
					
						
							| 
									
										
										
										
											2015-05-24 20:04:13 +06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-16 19:50:58 -05:00
										 |  |  |         webpage = self._download_webpage(url, video_id) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-24 20:04:13 +06:00
										 |  |  |         title = (self._html_search_meta('title', webpage, default=None) or | 
					
						
							|  |  |  |                  self._search_regex(r'<h1 class="title">([^<]+)</h1>')) | 
					
						
							| 
									
										
										
										
											2015-05-16 19:50:58 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-24 20:04:13 +06:00
										 |  |  |         video_id = self._search_regex( | 
					
						
							|  |  |  |             r'/config/video/(.+?)\.xml', webpage, 'video id') | 
					
						
							| 
									
										
										
										
											2015-05-16 19:50:58 -05:00
										 |  |  |         playlist = self._download_xml( | 
					
						
							| 
									
										
										
										
											2015-05-24 20:04:13 +06:00
										 |  |  |             'http://www.karrierevideos.at/player-playlist.xml.php?p=%s' % video_id, | 
					
						
							|  |  |  |             video_id, transform_source=fix_xml_ampersands) | 
					
						
							| 
									
										
										
										
											2015-05-16 19:50:58 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-24 20:04:13 +06:00
										 |  |  |         NS_MAP = { | 
					
						
							|  |  |  |             'jwplayer': 'http://developer.longtailvideo.com/trac/wiki/FlashFormats' | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         def ns(path): | 
					
						
							|  |  |  |             return xpath_with_ns(path, NS_MAP) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         item = playlist.find('./tracklist/item') | 
					
						
							|  |  |  |         video_file = xpath_text( | 
					
						
							|  |  |  |             item, ns('./jwplayer:file'), 'video url', fatal=True) | 
					
						
							|  |  |  |         streamer = xpath_text( | 
					
						
							|  |  |  |             item, ns('./jwplayer:streamer'), 'streamer', fatal=True) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         uploader = xpath_text( | 
					
						
							|  |  |  |             item, ns('./jwplayer:author'), 'uploader') | 
					
						
							|  |  |  |         duration = float_or_none( | 
					
						
							|  |  |  |             xpath_text(item, ns('./jwplayer:duration'), 'duration')) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         description = self._html_search_regex( | 
					
						
							|  |  |  |             r'(?s)<div class="leadtext">(.+?)</div>', | 
					
						
							|  |  |  |             webpage, 'description') | 
					
						
							| 
									
										
										
										
											2015-05-16 19:50:58 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-24 20:04:13 +06:00
										 |  |  |         thumbnail = self._html_search_meta( | 
					
						
							|  |  |  |             'thumbnail', webpage, 'thumbnail') | 
					
						
							|  |  |  |         if thumbnail: | 
					
						
							|  |  |  |             thumbnail = compat_urlparse.urljoin(url, thumbnail) | 
					
						
							| 
									
										
										
										
											2015-05-16 19:50:58 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return { | 
					
						
							|  |  |  |             'id': video_id, | 
					
						
							| 
									
										
										
										
											2015-05-24 20:04:13 +06:00
										 |  |  |             'url': streamer.replace('rtmpt', 'rtmp'), | 
					
						
							|  |  |  |             'play_path': 'mp4:%s' % video_file, | 
					
						
							|  |  |  |             'ext': 'flv', | 
					
						
							|  |  |  |             'title': title, | 
					
						
							| 
									
										
										
										
											2015-05-16 19:50:58 -05:00
										 |  |  |             'description': description, | 
					
						
							| 
									
										
										
										
											2015-05-24 20:04:13 +06:00
										 |  |  |             'thumbnail': thumbnail, | 
					
						
							|  |  |  |             'uploader': uploader, | 
					
						
							|  |  |  |             'duration': duration, | 
					
						
							| 
									
										
										
										
											2015-05-16 19:50:58 -05:00
										 |  |  |         } |